Major progress. Now the templates are being generated as they should