Reimplement as a state machine

Turned the main loop into a state machine (it's more like a giant
cherry^W^Wpushdown automaton) in preparation for adding further, more
complicated command-processing logic. I think this way should be cleaner.
Also added a few minor comments and made 'make clean' remove .pyc files.
Support user-defined categories

Added support for configurable sub-menus containing fixed lists of
executables. Updated the README to match.