Added support for accelerators in menu items. Tidied up more code.