CHG: code-generation only via templates (otherwise to difficult and unflexible)