Crazy amounts of refactoring. Still in progress but really needed to commit so I don't lose everything.
Some more work. Sorry for the lack of descriptive commits.