Added sanity check in all_affected_entities