More rewrite fixes and additions