Improve memory management on Tree