Refactored some code and moved controller class to separate module.