Minor patches to template engine