added bounds checking and heapify ops; buggy.