Consolidated MergeSort code