corrected some tree functions