Bug 9755: Refactor record merge functionality