Major refactor and addition of 'TreeManager'