Fix deletion of related_entities