Rewrite templator. Add functions.