More refactoring to simplify dependencies between modules