Bug fixes in the templates