Attempt another refactor of the merge code.