Minor fixes to key handling.