Refactor into several modules