Further work on the rewrite