Reorganized code. Commit before refactoring more.

On a mission to make this even more testable.