fixed a bug in the menu, and cleaned up some code