More refactoring of the codebase