simplfied templates generation (which also fixed a bug introduced in the last commit)