Lots of bugfixes. Also added identical-TreeNode-coalescing