Remove dead code and fix the rewrite failing tests.