Fix bug with duplicates in merge