More refactoring (WIP)