added tree caching