Minor fixes to the merging algorithm.