Modified the merge algorithm to automatically infer some mappings