Initial version of rewrite