Correctly prune keys when a model is removed.