clean up for rewrite