fixed many errors. Added graphviz dot output for tree