Throw a more appropriate exception when a template does not exist. Also, allow using a list of templates to be tried.