corrects the IDs of the entities