Did some rewriting