More progress on rewrite