Improving clustering and fixing heapsort.