cleanup code after small refactor of rewrite method.