Fix bug where manipulating deleted entities could cause a crash.