Refactoring: re-organize modules and classes