Rewrite templates