Fixed some bugs in deleteKey function.