many updates to tree code