Keyboard layout switches are now more gracefully handled. Closes issue #4.