Refactored some functionality into other modules