Added UIController, cleaned up code