massive refactoring wip