Fixed bugs with tree