Revised key handling
Added key/id handling