Added emergency key handling