Refactored TemplateUtil templateMemberExpander and modelExpandTemplates to avoid duplication