Create a common merge() function that can be adjusted in the next patch, because the logic for merging needs to be more complicated now.