restore fixes for templates, except the ones that affect variable expansion