Some modification to the merge code.