WIP on massive refactoring.