fixes a few bugs with tags and template.