Reorganize and refactor modules.