heap: merge fixes from trunk