key retrieval bug fixes