Fix hal2maf block tree export on leaf insertions.
Fix prioritizing reference node at the wrong time.

This caused very small blocks with leaf references.