build the rewriting code.