Refactor Tree a bit and add comments to it