Tested tree and small refactoring.