Fix issue with incorrect merging under certain circumstances.