Moved UI management and rendering to its own class.