Fixed bug in heap-delete function