Templating and error handling