Fixed up code a bit. Cleaned up comments and renamed troot to treeRoot.