Refactored lib into modules