Refactor into multiple modules