First rewriting pass