Some MainController refactoring