Improved tree manipulation, fixed bugs with pass through functions, started to add tests

Now a test treeprof object available to build tests on.