Extract library functionality from main.rs
This will allow developers to use the library by specifying it as a dependency, while at the same time keeping the binary's functionality unchanged.
Additionally, this will make it easier to add functionality to either part of the project.