Some refactoring of templates (mostly around charts).