Refactoring of tree stuff.