Added GUI helper functions and cleaned up GUI code