-finished refactoring tree blob to make it much easier to manipulate the tree