fixing todos, and some code in treebuild