Copied over the merge-in-place Go stuff.