Add void merging and tree construction. Needs more attention.