Cleanup for rewrite