Large refactoring that I do not want to talk about. All tests pass now anyway.