fixes to tree builder