slightly better key handling