Refactors mergesort variants