Bugfix in rewriter