Error handling.

Handling Left/Right modifier keys.
Some refactoring.