more robust locating of template files