More bugfixes for template work