anchor.diff:  
   (defconstant max-heap-size (- heap-size-limit 1))
   
  +(defun check-heap-clean (heap what &optional allow-traverse)
  +  (ecase (heap-state heap)
  +    (:clean t)
  +    (:dirty
  +     (error "Heap dirty on entry to ~S: ~S"
  +            what heap))
  +    (:traverse
  +     (unless allow-traverse
  +       (error "Cannot ~S while ~S is in progress: ~S"
  +              what 'map-heap heap)))))
  +
   (defun heap-insert (elt heap)
  -  "Insert ELT to HEAP. Returns ELT."
  +  "Insert ELT to HEAP. Returns ELT.
  +
  +Implicitly locks the heap during its operation."
     (declare (heap heap))
     (with-locked-heap (heap)
  -    (when (heap-dirty heap)
  -      (error "Heap dirty on entry to HEAP-INSERT."))
  +    (check-heap-clean heap 'heap-insert)
       (let* ((vector (heap-vector heap))
              (pred (heap-predicate heap))
              (size (heap-size heap))
  
positive.code:                                 (unless (> right count)
                                    (heap-insert right fringe)))))))))))))
  
  (defun map-heap (function heap)
    "Calls FUNCTION for each element in heap from top down, following the heap order."
    (declare (heap heap))
    (with-locked-heap (heap)
      (when (heap-dirty heap)
        (error "Heap dirty on entry to MAP-HEAP"))
      (let ((count (heap-count heap)))
        (unless (zerop count)
          (let* ((vector (heap-vector heap))
                 (pred (heap-predicate heap))
                 ;; Another heap to help us maintain order during traversal.
                 (fringe (make-heap (lambda (x y)
                                      (funcall pred (aref vector x) (aref vector y))))))
            ;; Grab the lock now so we don't need to do that repeatedly.
            (with-locked-heap (fringe)
              (heap-insert 1 fringe)
              (loop until (heap-empty-p fringe)
                    do (let* ((parent (heap-pop fringe))
                              (left (* 2 parent))
                              (right (1+ left)))
                         (funcall function (aref vector parent))
                         (unless (> left count)
                           (heap-insert left fringe))
                         (unless (> right count)
                           (heap-insert right fringe))))
              (heap-size fringe)))))))
  
  
negative.code:                                 (aref vector parent) child-data
                                  child parent))))))
      ;; Clean again
      (setf (heap-state heap) :clean)
      victim))
  
  (defun heap-delete (elt heap)
    "If ELT is in HEAP, removes it. Returns T if one or more references to ELT
  were found and removed, NIL otherwise.
  
  Implicitly locks the heap during its operation."
    (declare (type heap heap))
    (with-locked-heap (heap)
      (check-heap-clean heap 'heap-delete)
      (let* ((count (heap-count heap))
             (vector (heap-vector heap))
             (pred (heap-predicate heap)))
  