Removes duplicated code from merge.