Clean up UI code. Move main view code to its own class.