Making scan more space efficient
Using faster in-place mergesort