Changed the way entities are removed.