fixes for rewrite.