Fix bug in removing keys/values