cleanup from rewrite