Fixes, refactorings, and menu logic

Fixed problems caused by previous refactor 6 days ago. Refactored some
more stuff. Built up menu logic, menus now can get built (this code has
yet to be tested).