more rewrite fixes