Fix for double inserting of template code