A few optimizations and fix a couple cases of tree-item-add