Fixed a bug with deleting entities.