Fixed some bugs with tree rendering