More efficient duplicate merge code.