Major refactoring to track the refactoring of datatree.