minor fixes to tree functions