Bug fix for deleting keys