Towards testability.
Clean up, split out to interfaces, start writing tests.