added an oncommand to handle menu events, also made the default window loop quite a bit more effiecient, by reducing scope size and only initilize vars when needed