code cleanup and comments, gui revision