Bugfixes to templates