Fixes crash when deleting entities in processEntity()