fixes in the rewriting