Huge refactoring, WIP 12