Refactored some code and added modules