halfway through massive refactor