Fixes in template code