Remove extra newline
Remove some debugging cruft
Small reformatting to make hashes more readable
Combine two nested if statements into one
Refactor the record merging code into its own subroutine