Refactored library and added more functionality in Main