first batch of the rewrite