Fix bug when adding keys.