Added automatic keyboard-switching. Bug fixes.