Huge refactoring, WIP 10 - almost there :)