Fixed bug in templateName determination.