Cleaned up main controller.