Add options menu, code cleanup, and misc. bugfixes