Halfway through a big refactor

might as well commit...