Refactored to module pattern (prelim)
Commit refactor min