Cleaned up code and fixed a few bugs with keybindings.