Refactor to TreeManager