Cleanup, solving todos and refactoring for rewrite strategies.