Finishes in-progress refactoring from the controller module.
Refactors parts of the controller.