WIP 2: More refactoring