Fix duplicated IDs in entities