Bug fixing and code neatening.

Fixed a bug that disallowed action keys from being pressed when input
fields are selected when using Firefox. Additional small bug fixes.
Neatened code and fixed comments.