various fixes + template analyser