More robust templating