Better handling of invalid keys.