Fixed a bug where both the key and value was getting deleted from keydict