Refinements to quick sort implementation