Gui code cleanup