Added optional code to heapsortPRO