fixed bugs in tree extractor