Fixed some issues

changed problems with static variables and simpliied use of Gui.