fixed some bugs in trees