Clean up UI code a lot