Fixed per-foreign key TemplateFactory template. refs #474