Got the tree rewriter to work properly