Fixed bug in tree generation.