% This is a biblatex style file, originally adapted mainly from
% Lehman's standard.bbx and from chicago-notes.bbx.  It provides the
% reference list formatting for the Chicago author-date style.

\ProvidesFile{chicago-authordate.bbx}[2022/11/17 v 3.18b biblatex
bibliography style]

%%%% Initialize and format bibliography and los %%%%

\providetoggle{cms@citejtabb}% Here for Sourcemap declaration
\providetoggle{cms@bibjtabb}%

\DeclareFieldFormat{shorthandwidth}{#1}

\DeclareFieldFormat{shortserieswidth}{#1}

\DeclareFieldFormat{shortjournalwidth}{%
  \ifthenelse{\ifentrytype{jurisdiction}\OR%
    \ifentrytype{legal}\OR\ifentrytype{legislation}}%
  {\textbf{#1}\isdot}%
  {\mkbibemph{\textbf{#1}}\isdot}}%

\newlength{\lositemsep}
\newbibmacro*{begentry}{}

\defbibenvironment{bibliography}% New for 0.9a
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\defbibenvironment{shorthand}
  {\list
     {\printfield[shorthandwidth]{shorthand}}%
     {\setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{losnotes}
  {\list
     {\printfield[shorthandwidth]{shorthand}}%
     {\footnotesize%
      \setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{losendnotes}
  {\list
     {\printfield[shorthandwidth]{shorthand}}%
     {\enotesize%
      \setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist\nopunct\vspace{-\baselineskip}}% Kludges for endnotes
  {\item}

\defbibenvironment{shortjournal}%
  {\list
    {\printfield[shortjournalwidth]{shortjournal}}%
    {\setlength{\labelwidth}{\shortjournalwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.7\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{sjnotes}%
  {\list
    {\printfield[shortjournalwidth]{shortjournal}}%
    {\footnotesize%
      \setlength{\labelwidth}{\shortjournalwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{sjendnotes}%
  {\list
    {\printfield[shortjournalwidth]{shortjournal}}%
    {\enotesize%
      \setlength{\labelwidth}{\shortjournalwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist\nopunct\vspace{-\baselineskip}}
  {\item}

\defbibcheck{shorthand}{%
  \iftoggle{cms@los}%
  {\iffieldundef{shorthand}%
    {\skipentry}%
    {\ifcsdef{\strfield{shorthand}}%
      {\skipentry}%
      {\savefieldcs{shorthand}{\strfield{shorthand}}}}}%
  {}}%

\defbibcheck{shortjournal}{% Only one list
  \ifthenelse{\iffieldundef{shortjournal}\OR%
    \iffieldsequal{journaltitle}{shortjournal}\OR%
    \(\iffieldundef{journaltitle}\AND\(\ifentrytype{legal}\OR%
    \ifentrytype{legislation}\OR\ifentrytype{jurisdiction}\)\)}%
  {\skipentry}%
  {\ifcsdef{\strfield{shortjournal}}%
    {\skipentry}%
    {\savefieldcs{shortjournal}%
      {\strfield{shortjournal}}}}}%

% \defbibcheck{shortjournal}{% Multiple lists
%   \ifcsdef{cms@shjour}%
%   {\iffieldequals{shortjournal}{\cms@shjour}%
%     {\skipentry}%
%     {\savefield{shortjournal}{\cms@shjour}}}%
%   {\savefield{shortjournal}{\cms@shjour}}}

\defbibenvironment{shortseries}%
  {\list
    {\printfield[shortserieswidth]{shortseries}}%
    {\setlength{\labelwidth}{\shortserieswidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.7\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{shsernotes}%
  {\list
    {\printfield[shortserieswidth]{shortseries}}%
    {\footnotesize%
      \setlength{\labelwidth}{\shortserieswidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\defbibenvironment{shserendnotes}%
  {\list
    {\printfield[shortserieswidth]{shortseries}}%
    {\enotesize%
      \setlength{\labelwidth}{\shortserieswidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{.3\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\lositemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist\nopunct\vspace{-\baselineskip}}
  {\item}

\defbibcheck{shortseries}{% Only one list
  \ifthenelse{\iffieldundef{shortseries}\OR%
    \iffieldundef{series}\OR%
    \iffieldsequal{series}{shortseries}}%
  {\skipentry}%
  {\ifcsdef{\strfield{shortseries}}%
    {\skipentry}%
    {\savefieldcs{shortseries}%
      {\strfield{shortseries}}}}}%

\AtBeginBibliography{%
  \togglefalse{cms@headlessnote}}%

\AtEveryBibitem{%
  \global\csundef{@cmsst}}%

\AtEveryLositem{%
  \global\csundef{@cmsst}}%

\AtEveryBiblistitem{shortjournal}{%
  \global\csundef{@cmsst}%
  \ifthenelse{\ifentrytype{jurisdiction}\OR%
    \ifentrytype{legal}\OR\ifentrytype{legislation}}%
  {\clearlist{location}}%
  {}}%

\InitializeBibliographyStyle{%
  \let\bbx@lasthash\undefined}%

%%%% Bibliography-specific bibstrings %%%%

%% Now in *.lbx %%

%%%% Author, Editor, Translator, and Compiler  Macros %%%%

\renewbibmacro*{name:last-first}[4]{%
  \ifuseprefix
  {\usebibmacro{name:delim}{#3#1}%
    \usebibmacro{name:hook}{#3#1}%
    \ifblank{#3}{}{%
      \ifcapital
      {\mkbibnameprefix{\MakeCapital{#3}}\isdot}%
      {\mkbibnameprefix{#3}\isdot}%
      \ifpunctmark{'}{}{\addhighpenspace}}%
    \mkbibnamelast{#1}\isdot
    \ifblank{#2}{}{\addcomma\addlowpenspace\mkbibnamefirst{#2}\isdot}%
    \ifblank{#4}{}{\addcomma\addlowpenspace\mkbibnameaffix{#4}\isdot}}%
  {\usebibmacro{name:delim}{#1}%
    \usebibmacro{name:hook}{#1}%
    \mkbibnamelast{#1}\isdot%
    \ifblank{#2#3#4}{}{\addcomma}%
    \ifblank{#2}{}{\addlowpenspace\mkbibnamefirst{#2}\isdot}%
    \ifblank{#3}{}{\addlowpenspace\mkbibnameprefix{#3}\isdot}%
    \ifblank{#4}{}{\addcomma\addlowpenspace\mkbibnameaffix{#4}\isdot}}}

\renewbibmacro*{name:first-last}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\addlowpenspace}%
  \ifblank{#3}{}{%
    \mkbibnameprefix{#3}\isdot
    \ifpunctmark{'}%
    {}%
    {\ifuseprefix{\addhighpenspace}{\addlowpenspace}}}%
  \mkbibnamelast{#1}\isdot
  \ifblank{#4}{}{%
    \iftoggle{cms@jrcomma}%
    {\ifnumeral{#4}%
      {\addlowpenspace\mkbibnameaffix{#4}\isdot}%
      {\addcomma\addlowpenspace\mkbibnameaffix{#4}\isdot%
        \ifboolexpr{%
          test{\ifnumless{\value{listcount}}{\value{listtotal}}}%
          and
          test{\ifnumless{\value{listcount}}{\value{maxnames}}}%
        }%
        {\addcomma}%
        {}}}%
    {\addlowpenspace\mkbibnameaffix{#4}\isdot}}}%

\@ifpackagelater{biblatex}{2016/03/01}% For biblatex 3.3
{\renewbibmacro*{name:family-given}[4]{%
  \ifuseprefix
    {\usebibmacro{name:delim}{#3#1}%
     \usebibmacro{name:hook}{#3#1}%
     \ifdefvoid{#3}{}{%
       \ifcapital
         {\mkbibnameprefix{\MakeCapital{#3}}\isdot}%
         {\mkbibnameprefix{#3}\isdot}%
       \ifprefchar{}{\bibnamedelimc}}%
     \mkbibnamefamily{#1}\isdot
     \ifdefvoid{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{#2}\isdot}%
     \ifdefvoid{#4}{}{\revsdnamepunct\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}%
    {\usebibmacro{name:delim}{#1}%
     \usebibmacro{name:hook}{#1}%
     \mkbibnamefamily{#1}\isdot
     \ifboolexpr{%
       test {\ifdefvoid{#2}}%
       and
       test {\ifdefvoid{#3}}%
     }%
     {}{\revsdnamepunct}%
     \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}\isdot}%
     \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}%
     \ifdefvoid{#4}{}{\revsdnamepunct\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}}%

\renewbibmacro*{name:given-family}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \ifdefvoid{#2}{}{\mkbibnamegiven{#2}\isdot\bibnamedelimd}%
  \ifdefvoid{#3}{}{%
    \mkbibnameprefix{#3}\isdot
    \ifprefchar
      {}%
      {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
  \mkbibnamefamily{#1}\isdot
  \ifdefvoid{#4}{}{%
    \iftoggle{cms@jrcomma}%
    {\ifnumeral{#4}%
      {\bibnamedelimd\mkbibnamesuffix{#4}\isdot}%
      {\revsdnamepunct\bibnamedelimd\mkbibnamesuffix{#4}\isdot%
        \ifboolexpr{% Test needed?
          test{\ifnumless{\value{listcount}}{\value{listtotal}}}%
          and
          test{\ifnumless{\value{listcount}}{\value{maxnames}}}%
        }%
        {\revsdnamepunct}%
        {}}}%
    {\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}}}{}%

\renewbibmacro*{author/editor}{%
  \ifboolexpr{%
    test {\ifuseauthor}%
    or
    togl {cms@headlessnote}%
  }%
  {\usebibmacro{author}}%
  {\ifusenamea%
    {\usebibmacro{pickeditor}}%
    {\ifuseeditor%
      {\usebibmacro{moreeditor}}%
      {\ifusenameb%
        {\usebibmacro{picktranslator}}%
        {\ifusetranslator%
          {\usebibmacro{moretranslator}}%
          {\ifusenamec%
            {\usebibmacro{compiler}}%
            {\let\bbx@lasthash\undefined}}}}}}}%

\renewbibmacro*{author}{%
  \iftoggle{cms@headlessnote}%
  {\usebibmacro{justauthor}}%
  {\usebibmacro{moreauthor}}}

\newbibmacro*{justauthor}{%
  \ifthenelse{\ifnameundef{author}\OR\NOT\ifuseauthor}%
  {\let\bbx@lasthash\undefined}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}}%
      {\printtext{\bibnamedash}%
        \ifentrytype{customc}%
        {\newunit}%
        {\setunit{\nameaddonpunct}}\printfield{nameaddon}}}%
    {\iffieldequalstr{authortype}{anon}%
      {\bibopenbracket\printnames{author}%
        \ifentrytype{customc}%
        {\bibclosebracket%
          \usebibmacro{print+nameaddon}}%
        {\usebibmacro{print+nameaddon}%
          \bibclosebracket}%
        \savefield{fullhash}{\bbx@lasthash}}%
      {\iffieldequalstr{authortype}{anon?}%
        {\bibopenbracket\printnames{author}\addquestion%
          \ifentrytype{customc}%
          {\bibclosebracket%
            \usebibmacro{print+nameaddon}}%
          {\usebibmacro{print+nameaddon}%
            \bibclosebracket}%
          \savefield{fullhash}{\bbx@lasthash}}%
        {\iftoggle{cms@authorparens}%
          {\bibopenparen\printnames{author}%
            \ifentrytype{customc}%
            {\bibcloseparen\usebibmacro{print+nameaddon}}%
            {\usebibmacro{print+nameaddon}\bibcloseparen}}%
          {\printnames{author}%
            \usebibmacro{print+nameaddon}}%
          \savefield{fullhash}{\bbx@lasthash}}}}}}

\newbibmacro*{moreauthor}{%
  \ifthenelse{\ifnameundef{author}\OR\NOT\ifuseauthor}%
  {\usebibmacro{pickeditor}}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}}%
      {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
        \printfield{nameaddon}}}%
    {\iffieldequalstr{authortype}{anon}%
      {\bibopenbracket\printnames{author}%
        \usebibmacro{print+nameaddon}\bibclosebracket%
        \savefield{fullhash}{\bbx@lasthash}}%
      {\iffieldequalstr{authortype}{anon?}%
        {\bibopenbracket\printnames{author}\addquestion%
          \usebibmacro{print+nameaddon}\bibclosebracket%
          \savefield{fullhash}{\bbx@lasthash}}%
        {\iftoggle{cms@authorparens}%
          {\bibopenparen\printnames{author}%
            \usebibmacro{print+nameaddon}%
            \bibcloseparen}%
          {\printnames{author}%
            \usebibmacro{print+nameaddon}}%
          \savefield{fullhash}{\bbx@lasthash}}}}}}

\newbibmacro*{pickeditor}{%
  \ifthenelse{\ifnameundef{namea}\OR\NOT\ifusenamea}%
  {\usebibmacro{moreeditor}}%
  {\usebibmacro{parteditor}}}

\newbibmacro*{moreeditor}{%
  \ifthenelse{\ifnameundef{editor}\OR\NOT\ifuseeditor}%
    {\usebibmacro{picktranslator}}%
    {\ifboolexpr{%
        test {\iffieldequals{fullhash}{\bbx@lasthash}}%
        and
        not test {\iffirstonpage}%
        and
        togl {cms@namedash}%
      }%
      {\if@cms@nonameaddon%
        {\printtext{\bibnamedash}\editordelim}%
        {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
          \printfield{nameaddon}\editordelim}}%
       {\iftoggle{cms@authorparens}%
         {\bibopenparen\printnames{editor}%
           \usebibmacro{print+nameaddon}%
           \bibcloseparen\editordelim}%
         {\printnames{editor}%
           \usebibmacro{print+nameaddon}\editordelim}%
        \savefield{fullhash}{\bbx@lasthash}}%
     \usebibmacro{editstrg}}}%

\renewbibmacro*{editor}{%
  \iftoggle{cms@headlessnote}%
  {}%
  {\ifthenelse{\ifnameundef{namea}\OR\NOT\ifusenamea}%
    {\ifthenelse{\ifnameundef{editor}\OR\NOT\ifuseeditor}%
      {\usebibmacro{picktranslator}}%
      {\ifboolexpr{%
          test {\iffieldequals{fullhash}{\bbx@lasthash}}%
          and
          not test {\iffirstonpage}%
          and
          togl {cms@namedash}%
        }%
        {\if@cms@nonameaddon%
          {\printtext{\bibnamedash}\editordelim}%
          {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
            \printfield{nameaddon}\editordelim}}%
        {\iftoggle{cms@authorparens}%
          {\bibopenparen\printnames{editor}%
            \usebibmacro{print+nameaddon}%
            \bibcloseparen\editordelim}%
          {\printnames{editor}%
            \usebibmacro{print+nameaddon}\editordelim}%
          \savefield{fullhash}{\bbx@lasthash}}%
        \usebibmacro{editstrg}}}%
    {\ifboolexpr{%
        test {\iffieldequals{fullhash}{\bbx@lasthash}}%
        and
        not test {\iffirstonpage}%
        and
        togl {cms@namedash}%
      }%
      {\if@cms@nonameaddon%
        {\printtext{\bibnamedash}\nameadelim}%
        {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
          \printfield{nameaddon}\nameadelim}}%
      {\iftoggle{cms@authorparens}%
        {\bibopenparen\printnames[sortname]{namea}%
          \usebibmacro{print+nameaddon}%
          \bibcloseparen\nameadelim}%
        {\printnames[sortname]{namea}%
          \usebibmacro{print+nameaddon}\nameadelim}%
        \savefield{fullhash}{\bbx@lasthash}}%
      \usebibmacro{parteditstrg}}}}

\newbibmacro*{parteditor}{%
  \ifthenelse{\ifnameundef{namea}\OR\NOT\ifusenamea}%
  {\usebibmacro{picktranslator}}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}\nameadelim}%
      {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
        \printfield{nameaddon}\nameadelim}}%
    {\iftoggle{cms@authorparens}%
      {\bibopenparen\printnames[sortname]{namea}%
        \usebibmacro{print+nameaddon}%
        \bibcloseparen\nameadelim}%
      {\printnames[sortname]{namea}%
        \usebibmacro{print+nameaddon}\nameadelim}%
      \savefield{fullhash}{\bbx@lasthash}}%
    \usebibmacro{parteditstrg}}}

\newbibmacro*{picktranslator}{%
  \ifthenelse{\ifnameundef{nameb}\OR\NOT\ifusenameb}%
  {\usebibmacro{moretranslator}}%
  {\usebibmacro{parttranslator}}}

\newbibmacro*{moretranslator}{%
  \ifthenelse{\ifnameundef{translator}\OR\NOT\ifusetranslator}%
  {\usebibmacro{compiler}}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}\newcunit}%
      {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
        \printfield{nameaddon}\newcunit}}%
    {\iftoggle{cms@authorparens}%
      {\bibopenparen\printnames[sortname]{translator}%
        \usebibmacro{print+nameaddon}%
        \bibcloseparen\newcunit}%
      {\printnames[sortname]{translator}%
        \usebibmacro{print+nameaddon}\newcunit}%
      \savefield{fullhash}{\bbx@lasthash}}%
    \usebibmacro{transstrg}}}

\newbibmacro*{parttranslator}{%
  \ifthenelse{\ifnameundef{nameb}\OR\NOT\ifusenameb}%
  {\usebibmacro{compiler}}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}\newcunit}%
      {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
        \printfield{nameaddon}\newcunit}}%
    {\iftoggle{cms@authorparens}%
      {\bibopenparen\printnames[sortname]{nameb}%
        \usebibmacro{print+nameaddon}%
        \bibcloseparen\newcunit}%
      {\printnames[sortname]{nameb}%
        \usebibmacro{print+nameaddon}\newcunit}%
      \savefield{fullhash}{\bbx@lasthash}}%
    \usebibmacro{parttransstrg}}}

\newbibmacro*{compiler}{%
  \ifthenelse{\ifnameundef{namec}\OR\NOT\ifusenamec}%
  {\let\bbx@lasthash\undefined}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      not test {\iffirstonpage}%
      and
      togl {cms@namedash}%
    }%
    {\if@cms@nonameaddon%
      {\printtext{\bibnamedash}\newcunit}%
      {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
        \printfield{nameaddon}\newcunit}}%
    {\iftoggle{cms@authorparens}%
      {\bibopenparen\printnames[sortname]{namec}%
        \usebibmacro{print+nameaddon}%
        \bibcloseparen\newcunit}%
      {\printnames[sortname]{namec}%
        \usebibmacro{print+nameaddon}\newcunit}%
      \savefield{fullhash}{\bbx@lasthash}}%
    \usebibmacro{compilestrg}}}

\newbibmacro*{print+nameaddon}{%
  \ifboolexpr{%
    togl {cms@nona}%
    or
    test {\iffieldundef{nameaddon}}%
  }%
  {}%
  {\ifboolexpr{%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      and
      test {\iffieldequals{nameaddon}{\cms@lastna}}%
      and
      togl {cms@subseqnona}%
    }%
    {}%
    {\ifentrytype{customc}{\newunit}{\setunit{\nameaddonpunct}}%
      \printfield{nameaddon}%
      \savefield{nameaddon}{\cms@lastna}}}}%

\def\if@cms@nonameaddon{%
  \ifboolexpr{%
    test {\iffieldundef{nameaddon}}%
    or
    togl {cms@nona}%
    or
    (
    test {\iffieldequals{nameaddon}{\cms@lastna}}%
    and
    togl {cms@subseqnona}%
    )
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}%

\DeclareDelimFormat{revsdnamedelim}{\finalandcomma}%

\DeclareNameAlias{author}{sortname}% Needed in 0.9
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}

%%%% Drivers for Bibliography entries and Shorthands %%%%

\DeclareBibliographyDriver{shorthand}{%
  \iftoggle{cms@los}%
  {\ifnameundef{labelname}%
    {\mkbibemph{\bibstring{see}}%
      \addspace%
      \usebibmacro{shorthand:label}}%
    {\mkbibemph{\bibstring{see}}%
      \addspace%
      \ifboolexpr{%
        test {\iffieldequalstr{labelnamesource}{shortauthor}}%
        and
        (
        test {\ifentrytype{manual}}%
        or
        test {\ifentrytype{standard}}%
        )
      }%
      {\printnames{\thefield{labelnamesource}}}%
      {\ifentrytype{customc}%
        {\clearfield{nameaddon}}%
        {}%
        \usebibmacro{author/editor}}}%
    \finentry}%
  {\iftoggle{cms@fullshhand}%
    {\usedriver{\frenchspacing}%
      {\thefield{entrytype}}%
      \finentry}%
    {\ifnameundef{labelname}%
      {\ifthenelse{\iffieldequalstr{entrysubtype}{magazine}\AND\NOT%
          \ifentrytype{periodical}}%
        {\printfield[journaltitle]{journaltitle}\newcunit}%
        {\ifthenelse{\ifentrytype{manual}\OR\ifentrytype{standard}}%
          {\printlist{organization}\newcunit}%
          {}}}%
      {\ifboolexpr{%
          test {\iffieldequalstr{labelnamesource}{shortauthor}}%
          and
          (
          test {\ifentrytype{manual}}%
          or
          test {\ifentrytype{standard}}%
          )
        }%
        {\printnames{\thefield{labelnamesource}}\newunit}%
        {\ifthenelse{\ifentrytype{customc}\OR\ifentrytype{dataset}}%
          {\usebibmacro{justauthor}}% Moved \addspace to field format (2.1)
          {\usebibmacro{author/editor}\newunit}}}%
      \printfield[lostitle]{title}%
      \finentry}}}

\DeclareBibliographyDriver{shortjournal}{%
  \ifentrytype{periodical}%
  {\iffieldundef{title}%
    {\printfield{titleaddon}}%
    {\printtext[title]{%
        \printfield[tnoformat]{title}%
        \setunit{\subtitlepunct}%
        \printfield[stnoformat]{subtitle}}%
      \setunit{\jtitleaddonpunct}%
      \printfield{titleaddon}}%
    \setunit{\addspace}%
    \printlist[periodplace]{location}}%
  {\iffieldundef{journaltitle}%
    {\printfield{journaltitleaddon}}%
    {\printtext[journaltitle]{%
        \printfield[jtnoformat]{journaltitle}%
        \setunit{\subtitlepunct}%
        \printfield[sjtnoformat]{journalsubtitle}}%
      \setunit{\jtitleaddonpunct}%
      \printfield{journaltitleaddon}}%
    \setunit{\addspace}%
    \printlist[periodplace]{location}}%
  \finentry}%

\DeclareBibliographyDriver{shortseries}{%
  \printfield{series}\finentry}

\DeclareStyleSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{periodical}
      \step[fieldsource=shorttitle, final]
      \step[fieldset=shortjournal, origfieldval]
    }
    \map{
      \step[fieldsource=pubstate,
      match=\regexp{forthcoming|inpreparation|submitted|inpress}, final]
      \step[fieldset=year, origfieldval, final]
      \step[fieldsource=year,
      match=\regexp{(forthcoming|inpreparation|submitted|inpress)},
      replace=\regexp{\\bibstring\{$1\}}]%$
      \step[fieldset=pubstate, null]
    }
    \map{
      \pertype{article}
      \pertype{periodical}
      \pertype{review}
      \pertype{suppperiodical}
      \step[fieldsource=entrysubtype, match={newspaper},
      replace={magazine}]
    }
    \map{
      \pertype{jurisdiction}
      \pertype{legal}
      \pertype{legislation}
      \step[fieldsource=journaltitle, final]
      \step[fieldset=shortjournal, origfieldval]
    }
    \map[overwrite]{
      \pertype{jurisdiction}
      \step[fieldsource=shortjournal, match=\regexp{[^\\adddot][a-z]}, final]
      \step[fieldset=shortjournal, fieldvalue=\addnbspace, append]
    }
    \map{
      \pertype{legislation}
      \step[fieldsource=title, match=\regexp{Const}, final]
      \step[fieldset=entrysubtype, fieldvalue=constitution]
    }
    \map{
      \pertype{legislation}
      \step[fieldsource=entrysubtype, match=\regexp{canada}, final]
      \step[fieldsource=bookpagination, match={section},
      replace={canadasection}]
      \step[fieldsource=pagination, match={section},
      replace={canadasection}]
    }
    \map[overwrite]{
      \step[fieldsource=subtitle, final]
      \step[fieldsource=title,
      match=\regexp{\\(mkbib|en)quote\{.+((\?|\!)\})$},%$
      final]
      \step[fieldset=title, fieldvalue=\csgdef{@cmsst}{\@ne}, append]
    }
    \map[overwrite]{
      \step[fieldsource=booksubtitle, final]
      \step[fieldsource=booktitle,
      match=\regexp{\\(mkbib|en)quote\{.+((\?|\!)\})$},%$
      final]
      \step[fieldset=booktitle, fieldvalue=\csgdef{@cmsst}{\@ne}, append]
    }
    \map[overwrite]{
      \step[fieldsource=issuesubtitle, final]
      \step[fieldsource=issuetitle,
      match=\regexp{\\(mkbib|en)quote\{.+((\?|\!)\})$},%$
      final]
      \step[fieldset=issuetitle, fieldvalue=\csgdef{@cmsst}{\@ne}, append]
    }
    \map[overwrite]{
      \step[fieldsource=journalsubtitle, final]
      \step[fieldsource=journaltitle,
      match=\regexp{\\(mkbib|en)quote\{.+((\?|\!)\})$},%$
      final]
      \step[fieldset=journaltitle, fieldvalue=\csgdef{@cmsst}{\@ne}, append]
    }
    \map[overwrite]{
      \step[fieldsource=mainsubtitle, final]
      \step[fieldsource=maintitle,
      match=\regexp{\\(mkbib|en)quote\{.+((\?|\!)\})$},%$
      final]
      \step[fieldset=maintitle, fieldvalue=\csgdef{@cmsst}{\@ne}, append]
    }
    \map{
      \pertype{standard}
      \step[notfield=author, final]
      \step[fieldsource=organization, final]
      \step[fieldsource=organization, match=\regexp{(.*)}]
      \step[fieldset=shortauthor, fieldvalue=\regexp{{$1}}]%$
    }
    \map{
      \pertype{manual}
      \step[notfield=author, final]
      \step[notfield=editor, final]
      \step[fieldsource=organization, final]
      \step[fieldsource=organization, match=\regexp{(.*)}]
      \step[fieldset=shortauthor, fieldvalue=\regexp{{$1}}]%$
    }
    \map[overwrite]{
      \pertype{review}
      \pertype{online}
      \pertype{suppperiodical}
      \step[fieldsource=relatedtype, match=\regexp{commenton}, final]
      \step[fieldsource=options, final]
      \step[fieldsource=options, notmatch=\regexp{skipbib|cmsdate}, final]
      \step[fieldset=options, fieldvalue={,skipbib,cmsdate=full},
      append]
      \step[notfield=verbc, final]
      \step[fieldsource=entrykey]
      \step[fieldset=verbc, origfieldval]
    }
    \map{
      \pertype{review}
      \pertype{online}
      \pertype{suppperiodical}
      \step[fieldsource=relatedtype, match=\regexp{commenton}, final]
      \step[notfield=options, final]
      \step[fieldset=options, fieldvalue={skipbib,cmsdate=full}]
      \step[fieldsource=entrykey]
      \step[fieldset=verbc, origfieldval]
    }
    \map{
      \pertype{review}
      \pertype{online}
      \pertype{suppperiodical}
      \step[fieldsource=relatedtype, match=\regexp{commenton}, final]
      \step[fieldsource=related, match=\regexp{(.*)}]
      \step[entrynew=$1-customc, entrynewtype=customc]%$
      \step[fieldset=options, fieldvalue={skipbib,authortitle},
      entrytarget=$1-customc]%$
      \step[fieldset=pubstate, fieldvalue=cms-generated,
      entrytarget=$1-customc]%$
      \step[fieldsource=relatedtype]
      \step[fieldsource=relatedstring]
      \step[fieldset=title, origfieldval, entrytarget=$1-customc]%$
    }
    \map{
      \pertype{video}
      \step[fieldsource=entrysubtype, match=tvepisode, final]
      \step[fieldsource=title, final]
      \step[fieldsource=booktitle, final]
      \step[fieldset=sorttitle, origfieldval]
    }
    \map[overwrite]{
      \pertype{customc}
      \step[fieldsource=title,
      match=\regexp{\\citeincite(\{|\[[^\]]*\]\[\]\{)([^\}]+)\}$},%$
      replace=\regexp{\\citeincitef$1$2\}}]
      \step[fieldsource=title,
      match=\regexp{\\citeincites(((\{|(\[[^\]]*\])+\{|\([^\)]*\)\(\)\{|\([^\)]*\)\(\)(\[[^\]]*\])+\{)[^\}]+\})+)((\{|\[[^\]]*\]\[\]\{)[^\}]+)\}$},%$
      replace=\regexp{\\citeincitefs$1$6\}}]
    }
    \map[overwrite, foreach={titleaddon,annotation,annote,addendum,note}]{
      \step[fieldsource=$MAPLOOP,
      match=\regexp{\\citeincite(\{|\[[^\]]*\]\[\]\{)([^\}]+)\}$},%$
      replace=\regexp{\\citeincitef$1$2\}}]
      \step[fieldsource=$MAPLOOP,
      match=\regexp{\\citeincites(((\{|(\[[^\]]*\])+\{|\([^\)]*\)\(\)\{|\([^\)]*\)\(\)(\[[^\]]*\])+\{)[^\}]+\})+)((\{|\[[^\]]*\]\[\]\{)[^\}]+)\}$},%$
      replace=\regexp{\\citeincitefs$1$6\}}]
    }
    \map[overwrite]{% Backward compatibility kludges
      \step[fieldsource=year,
      match=\regexp{^\[(.+)\](.*)},
      replace=\regexp{\[$1\]\\midsentence$2}]
      \step[fieldsource=year,
      match=\regexp{^\\bibopenbracket\s*(.+)\\bibclosebracket(.*)},
      replace=\regexp{\[$1\]\\midsentence$2}]
      \step[fieldsource=year,
      match=\regexp{^\\mkbibbrackets\{(.+)\}(.*)},
      replace=\regexp{\[$1\]\\midsentence$2}]
    }
  }
}%

\DeclareBibliographyDriver{article}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{mag+news+author}%
  \newunit\newblock
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \usebibmacro{mag+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock%
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock%
  \usebibmacro{bibreprint}%
  \usebibmacro{issuetitle}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{byeditor+others}%
  \newunit\newblock% 17th ed. clarifies punctuation
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{mag+news+date}%
  \newunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \usebibmacro{chap+pag}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}
{\usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef{\bbx@lasthash}{\usebibmacro{mag+news+title}\newunit}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef{\bbx@lasthash}{}{\usebibmacro{mag+news+title}}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit*{\newunitpunct}\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock%
  \usebibmacro{bibreprint}%
  \usebibmacro{issuetitle}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{byeditor+others}%
  \newunit\newblock% 17th ed.
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock% (changed for 0.7)??
  \iftoggle{cms@switchdates}%
  {\usebibmacro{journal+issue+year+pages}{orig}}%
  {\usebibmacro{journal+issue+year+pages}{}}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{artwork}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}[1]% 17th ed. ??
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \usebibmacro{artwork+dates}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \newunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield[type]{version}%
  \newcunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{institution+organization}%
  \setunit*{\addcomma\addspace}\newblock
  \printlist{location}%
  \newunit\newblock
  \printfield{howpublished}%
  \setunit*{\addspace}%
  \usebibmacro{music+eventdate}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{audio}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    and
    (
    not test {\iffieldundef{title}}%
    or
    not test {\iffieldundef{titleaddon}}%
    )
  }%
  {\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    or
    (
    test {\iffieldundef{title}}%
    and
    test {\iffieldundef{titleaddon}}%
    )
  }%
  {}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock
  \usebibmacro{music+eventdate}% 17th ed.
  \ifthenelse{\iffieldundef{eventyear}\AND\NOT%
    \(\iffieldundef{title}\AND\iffieldundef{titleaddon}\)}%
  {\newcunit}%
  {\newunit}%
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \iffieldundef{booktitle}%
  {\setunit{\newunitpunct}}% Fix customc?
  {\setunit{\addcomma\addspace}}%
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \usebibmacro{editorpunct}%\newunit% unit, not cunit?
  \usebibmacro{bybookauthor}%
  \usebibmacro{byeditor+others}%
  \newunit% ??? Editorpunct maybe not right here?
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext{%
        \printfield{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}%
    {\printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring[\cms@ofwrap]{ofseries}%
      \iftoggle{smartof}{}{\setunit{\addspace}}%
      \printtext{%
        \printfield[title:hook:alt]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}% Reversed with bibreprint 16th ed. (?)
  \newunit\newblock
  \usebibmacro{bibreprint}%\printorigdate%
  \usebibmacro{publ+loc+year}%
  \newunit
  \printfield{type}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isan}%
    \setunit*{\addcomma\addspace}\newblock%
    \printfield{ismn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%

\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}%
    \setunit*{\addcomma\addspace}%
    \usebibmacro{version}}%
  {}%
  \newunit\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@bookcrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@bookcrossref}%
    }%
  {\usebibmacro{mtitle+mstitle+vol+part+title+stitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \iffieldundef{version}%
  {}%
  {\printfield{version}}
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \usebibmacro{editorpunct}%
  \iftoggle{cms@bookpages}%
  {}%
  {\clearfield{pages}}%
  \printfield{chapter}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newcunit\newblock
  \printlist[][-\value{listtotal}]{lista}%
  \newunit\newblock
  \printfield{type}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{bookinbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newunit\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \setunit*{\newunitpunct}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@bookcrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@bookcrossref}%
    }%
  {\usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \printfield{chapter}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{booklet}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{howpubl+loc+year}%
  \newunit\newblock
  \usebibmacro{chap+pag}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{collection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@bookcrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@bookcrossref}%
    }%
  {\usebibmacro{mtitle+mstitle+vol+part+title+stitle}%
  \usebibmacro{editorpunct}%
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{volume+or+volumes}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{customc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{justauthor}%
  \ifboolexpr{%
    test {\iffieldundef{nameaddon}}%
    or
    togl {cms@nona}%
  }%
  {\newunit}%
  {\setunit{\addspace}}%
  \usebibmacro{italtitle+stitle}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{dataset}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock%
  \printtext[parens]{%
    \printfield{title}%
    \setunit{\subtitlepunct}%
    \printfield[noformat]{subtitle}%
    \setunit{\ctitleaddonpunct}%
    \printfield{titleaddon}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \newunit% 16th ed.
    \usebibmacro{byauthor}%
    \newunit\newblock
    \usebibmacro{byeditor+others}%
    \setunit{\addspace}\newblock%
    \ifthenelse{\iffieldundef{howpublished}\AND%
      \iffieldundef{number}\AND\iffieldundef{type}}%
    {}%
    {\printtext[parens]{%
        \printfield{howpublished}%
        \newcunit
        \printfield{type}%
        \setunit{\addspace}%
        \printfield{number}}}%
    \newunit\newblock
    \printfield{version}%
    \newunit\newblock
    \printfield{note}%
    \newunit\newblock
    \usebibmacro{institution+organization}%
    \setunit*{\addcomma\addspace}\newblock
    \printlist{location}%
    \setunit{\addsemicolon\addspace}%
    \printurldate%
    \ifboolexpr{%
      togl {cms@urltime}%
      and
      not test {\iffieldundef{urlhour}}%
    }%
    {\newcunit\printurltime}%
    {}}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{date}%
  \clearfield{urlyear}\clearfield{urlmonth}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{image}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}[1]%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock% 16th ed. added * (?)
  \usebibmacro{artwork+dates}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \newunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield[type]{version}%
  \newcunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{institution+organization}%
  \setunit*{\addcomma\addspace}\newblock
  \printlist{location}%
  \newunit\newblock
  \printfield{howpublished}%
  \setunit*{\addspace}%
  \usebibmacro{music+eventdate}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \setunit{\newunitpunct}% 16th ed.
  \usebibmacro{byauthor}%
  \setunit{\newunitpunct}%
  \usebibmacro{part+editor+translator}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@crossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@crossref}%
    }%
  {\setunit{\newunitpunct}%
  \usebibmacro{chapincoll}%
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{incollection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \setunit{\newunitpunct}% 16th ed.
  \usebibmacro{byauthor}%
  \setunit{\newunitpunct}%
  \usebibmacro{part+editor+translator}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@crossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@crossref}%
    }%
  {\setunit{\newunitpunct}% Moved here.
  \usebibmacro{chapincoll}%
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{inproceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \setunit{\newunitpunct}% 16th ed.
  \usebibmacro{byauthor}%
  \setunit{\newunitpunct}%
  \usebibmacro{part+editor+translator}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@crossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@crossref}%
    }%
  {\setunit{\newunitpunct}%
    \usebibmacro{chapincoll}%
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit\newblock
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \printfield{note}%
  \setunit*{\addcomma\addspace}%
  \printfield{eventtitle}%
  \setunit{\ctitleaddonpunct}%
  \printfield{eventtitleaddon}%
  \newcunit%
  \printfield{venue}%
  \newcunit\newblock
  \printeventdate%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{org+publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{reference+title}%{italtitle+stitle}
  \newunit\newblock
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \setunit*{\newunitpunct}% need asterisk?
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \printfield{chapter}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newcunit\newblock
  \printlist[][-\value{listtotal}]{lista}%
  \newcunit\newblock% \setunit{\addspace}% 16th ed.
  \ifnameundef{author}%
  {}%
  {\printtext{% 16th ed.
      \bibstring{by}%
      \addspace%
      \printnames[byauthor]{author}}}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{jurisdiction}{%
  \iffieldequalstr{entrysubtype}{square}% FIXME?
  {\usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \usebibmacro{clegis+news+title}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{byauthor}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cpart+editor+translator}%
    \newcunit%
    \usebibmacro{issuetitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cbyeditor+others}%
    \setunit{\addcomma\addspace}%
    \printfield[juridnum]{number}%
    \newcunit%
    \iffieldundef{year}%
    {}%
    {\printtext[brackets]{%
      \begingroup% Better ideas?
      \let\abx@bibmonth\blx@imc@bibsstring%
      \usebibmacro{date}\endgroup}}%
    \setunit*{\addspace}%
    \printfield[jourvol]{volume}%
    \setunit{\addnbspace}%
    \iffieldundef{shortjournal}%
    {}%
    {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
    \iffieldundef{issue}%
    {\printfield[jurisdictionser]{series}}%
    {\setunit{\addspace}%
      \printfield{issue}}% Better ideas?
    \usebibmacro{juridpostnote}%
    \setunit{\addcomma\addspace}%
    \printfield{note}%
    \setunit{\addspace}%
    \printlist{location}%
    \setunit{\addspace}%
    \usebibmacro{cms:shorthandintro}%
    \setunit{\addspace}\newblock
    \printfield{addendum}%
    \newcunit\newblock
    \iftoggle{cms@isbn}%
    {\printfield{issn}}%
    {}%
    \newcunit\newblock
    \usebibmacro{cite+doi+url}%
    \newcunit\newblock
    \usebibmacro{pageref}%
    \newcunit\newblock
    \iftoggle{cms@related}%
    {\usebibmacro{related:init}%
      \usebibmacro{related}%
      \newcunit}%
    {}%
    \usebibmacro{finentry}}
  {\iffieldequalstr{entrysubtype}{round}% FIXME?
    {\usebibmacro{bibindex}%
      \usebibmacro{begentry}%
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \newcunit%
      \iffieldundef{year}%
      {}%
      {\printtext[parens]{%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \setunit*{\addspace}%
      \printfield[jourvol]{volume}%
      \setunit{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \iffieldundef{issue}%
      {\printfield[jurisdictionser]{series}}%
      {\setunit{\addspace}%
        \printfield{issue}}% Better ideas?
      \usebibmacro{juridpostnote}%
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \setunit{\addspace}%
      \printlist{location}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \setunit{\addspace}\newblock
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \iftoggle{cms@related}%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}
    {\usebibmacro{bibindex}%
      \usebibmacro{begentry}%
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \iffieldundef{issue}%
      {\printfield[jurisdictionser]{series}}%
      {\setunit{\addspace}%
        \printfield{issue}}% Better ideas?
      \setunit{\addspace}%
      \printlist{origpublisher}%
      \usebibmacro{juridpostnote}%
      \setunit{\addcomma\addspace}%
      \printlist{origlocation}%
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \setunit{\addspace}%
      \ifboolexpr{%
        test {\iffieldundef{year}}%
        and
        test {\iflistundef{location}}%
      }%
      {}%
      {\printtext[parens]{%
        \printlist{location}%
        \setunit*{\addspace}%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \setunit{\addspace}\newblock
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \iftoggle{cms@related}%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}}}

\DeclareBibliographyDriver{legal}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor}%
  \newcunit\newblock
  \usebibmacro{clegis+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield[juridnum]{number}%
  \newcunit%
  \iffieldundef{year}%
  {}%
  {\printtext{%
    \begingroup% Better ideas?
    \let\abx@bibmonth\blx@imc@bibsstring%
    \usebibmacro{date}\endgroup}}%
  \newcunit%\setunit*{\addspace}%
  \printfield[jourvol]{volume}%
  \setunit*{\addnbspace}%
  \iffieldundef{shortjournal}%
  {}%
  {\printtext[shortjournal]{%
    \printfield[jtsnoformat]{shortjournal}}}%
  \setunit{\addspace}%
  \printfield{series}%
  \setunit{\addspace}%
  \printfield{issue}%
  \newcunit%
  \printfield{part}%
  \newcunit%
  \printfield{chapter}%
  \usebibmacro{juridpostnote}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addspace}%
  \printlist{location}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \setunit{\addspace}\newblock%
  \printfield{addendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \newcunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newcunit}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{legislation}{%
  \iffieldequalstr{entrysubtype}{uk}% FIXME?
  {\usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \usebibmacro{author/editor}%
    \newcunit\newblock
    \usebibmacro{clegis+news+title}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{byauthor}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cpart+editor+translator}%
    \newcunit%
    \usebibmacro{issuetitle}%
    \setunit{\addcomma\addspace}%
    \usebibmacro{cbyeditor+others}%
    \setunit{\addcomma\addspace}%
    \printfield[juridnum]{number}%
    \setunit{\addcomma\addspace}%
    \printfield{note}%
    \newcunit%
    \iffieldundef{year}%
    {}%
    {\printtext{%
      \begingroup% Better ideas?
      \let\abx@bibmonth\blx@imc@bibsstring%
      \usebibmacro{date}\endgroup}}%
    \newcunit%\setunit*{\addspace}%
    \printfield[jourvol]{volume}%
    \setunit*{\addnbspace}%
    \iffieldundef{shortjournal}%
    {}%
    {\printtext[shortjournal]{%
      \printfield[jtsnoformat]{shortjournal}}}%
    \setunit{\addspace}%
    \printfield{series}%
    \setunit{\addspace}%
    \printfield{issue}%
    \newcunit%
    \printfield{part}%
    \newcunit%
    \printfield{chapter}%
    \usebibmacro{juridpostnote}%
    \setunit{\addspace}%
    \printlist{location}%
    \setunit{\addspace}%
    \usebibmacro{cms:shorthandintro}%
    \setunit{\addspace}\newblock%
    \printfield{addendum}%
    \newcunit\newblock
    \iftoggle{cms@isbn}%
    {\printfield{issn}}%
    {}%
    \newcunit\newblock
    \usebibmacro{cite+doi+url}%
    \newcunit\newblock
    \usebibmacro{pageref}%
    \newcunit\newblock
    \iftoggle{cms@related}%
    {\usebibmacro{related:init}%
      \usebibmacro{related}%
      \newcunit}%
    {}%
    \usebibmacro{finentry}}
  {\iffieldequalstr{entrysubtype}{hansard}% FIXME?
    {\usebibmacro{bibindex}%
      \usebibmacro{begentry}%
      \usebibmacro{author/editor}%
      \newcunit\newblock
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addcomma\addspace}%
      \printfield[juridnum]{number}%
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \setunit{\addspace}%
      \printfield[hansardser]{series}%
      \setunit{\addspace}%
      \iffieldundef{year}%
      {}%
      {\printtext[parens]{%
        \begingroup% Better ideas?
        \let\abx@bibmonth\blx@imc@bibsstring%
        \usebibmacro{date}\endgroup}}%
      \usebibmacro{juridpostnote}%
      \setunit{\addspace}%
      \printlist{location}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \setunit{\addspace}\newblock%
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \iftoggle{cms@related}%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}
    {\usebibmacro{bibindex}%
      \usebibmacro{begentry}%
      \usebibmacro{author/editor}%
      \newcunit\newblock
      \usebibmacro{clegis+news+title}%
      \setunit{\addspace}%
      \usebibmacro{language+transtitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{byauthor}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cpart+editor+translator}%
      \newcunit%
      \usebibmacro{issuetitle}%
      \setunit{\addcomma\addspace}%
      \usebibmacro{cbyeditor+others}%
      \setunit{\addspace}% FIXME?
      \printfield[juridnum]{number}%
      \setunit{\addcomma\addspace}%
      \printfield{note}%
      \newcunit%
      \printfield[jourvol]{volume}%
      \setunit*{\addnbspace}%
      \iffieldundef{shortjournal}%
      {}%
      {\printtext[shortjournal]{%
        \printfield[jtsnoformat]{shortjournal}}}%
      \newcunit%
      \printfield{series}%
      \setunit{\addspace}%
      \printfield{issue}%
      \newcunit%
      \printfield{part}%
      \newcunit%
      \printfield{chapter}%
      \usebibmacro{juridpostnote}%
      \setunit{\addspace}%
      \ifboolexpr{%
        test {\iffieldundef{year}}%
        and
        test {\iffieldundef{usera}}%
        and
        test {\iflistundef{location}}%
      }%
      {}%
      {\printtext[parens]{%
          \printlist{location}%
          \setunit*{\addspace}%
          \printfield{usera}%
          \setunit*{\addspace}%
          \begingroup% Better ideas?
          \let\abx@bibmonth\blx@imc@bibsstring%
          \usebibmacro{date}\endgroup}}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \setunit{\addspace}\newblock%
      \printfield{addendum}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{issn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \newcunit\newblock
      \iftoggle{cms@related}%
      {\usebibmacro{related:init}%
        \usebibmacro{related}%
        \newcunit}%
      {}%
      \usebibmacro{finentry}}}}

\DeclareBibliographyDriver{letter}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \printtext[title]{%
    \printfield[noformat]{title}}%
  \setunit{\ctitleaddonpunct}%
  \printfield{titleaddon}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{letter+date}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock%\bibsentence
  \usebibmacro{part+editor+translator}%
  \setunit*{\newunitpunct}%
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@crossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@crossref}%
    }%
  {\usebibmacro{chapincoll}%
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\newunit}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\newunit}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{manual}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author+org}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \usebibmacro{edition}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \printfield{type}%
  \newunit
  \printfield{note}%
  \newunit\newblock%
  \usebibmacro{bibreprint}%
  \usebibmacro{org+publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{misc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \iffieldundef{entrysubtype}%
  {\ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}}%
  {}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \iffieldundef{entrysubtype}%
  {\ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}}%
  {\printfield{title}%
    \setunit{\subtitlepunct}%
    \printfield[noformat]{subtitle}%
    \setunit{\ctitleaddonpunct}%
    \printfield{titleaddon}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \newcunit\newblock%
    \usebibmacro{unpubl+letter+date}%
    \newcunit
    \printlist{origlocation}}% 17th ed.
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \printfield{howpublished}%
  \newunit\newblock
  \printfield{type}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \iffieldundef{entrysubtype}%
  {\printfield{venue}\setunit*{\addcomma\addspace}}%
  {}%
  \usebibmacro{misc+institution+organization}%
  \setunit*{\addcomma\addspace}\newblock
  \printlist{location}%
  \iffieldundef{entrysubtype}%
  {\newcunit\newblock%
    \usebibmacro{date}}%
  {}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{music}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    and
    (
    not test {\iffieldundef{title}}%
    or
    not test {\iffieldundef{titleaddon}}%
    )
  }%
  {\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    or
    (
    test {\iffieldundef{title}}%
    and
    test {\iffieldundef{titleaddon}}%
    )
  }%
  {}{\usebibmacro{italtitle+stitle}}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock
  \ifthenelse{\iffieldundef{booktitle}\AND\iffieldundef{entrysubtype}}%
  {\usebibmacro{byeditor+others}\newunit\newblock}{}%
  \usebibmacro{music+eventdate}%\printeventdate
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \printfield{howpublished}%
  \newunit\newblock
  \usebibmacro{chap+as+track}%inscore% 17th ed.
  \usebibmacro{music+bookauthor}% Ditto.
  \usebibmacro{btitle+bstitle}%
  \iffieldundef{booktitle}%
  {\newunit}% Fix customc?
  {\newcunit}%
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \usebibmacro{editorpunct}%\newunit% unit, not cunit?
  \ifthenelse{\iffieldundef{booktitle}\AND\iffieldundef{entrysubtype}}%
  {}{\usebibmacro{byeditor+others}}%
  \newunit% ??? Editorpunct maybe not right here?
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext{%
        \printfield{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}%
    {\printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring[\cms@ofwrap]{ofseries}%
      \iftoggle{smartof}{}{\setunit{\addspace}}%
      \printtext{%
        \printfield[title:hook:alt]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{ctitleaddonpunct}%
      \printfield{maintitleaddon}}}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{music+origdate}% Changed for 17th ed.
  \newunit\newblock
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}\newblock
  \usebibmacro{series+or+shortser}%
  \ifboolexpr{test {\iflistundef{publisher}} and test {\iffieldundef{series}}}%
  {\newunit}%
  {\setunit{\addspace}}%
  \printfield{number}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newunit
  \usebibmacro{institution+organization}%
  \setunit*{\addcomma\addspace}\newblock
  \printlist{location}%
  \newcunit\newblock
  \printfield{type}%
  \newunit\newblock
  \usebibmacro{pubstate}% 16th ed -- origdate instead, as above?
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{iswc}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{mvbook}{book}

\DeclareBibliographyAlias{mvcollection}{collection}

\DeclareBibliographyAlias{mvproceedings}{proceedings}

\DeclareBibliographyAlias{mvreference}{reference}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash%
  {\ifboolexpr{%
      togl {cms@related}%
      and
      test {\iffieldequalstr{relatedtype}{commenton}}%
    }%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{titleaddon}}%
      {\usebibmacro{related:init}%
        \usebibmacro{related}}%
      {\usebibmacro{italtitle+stitle}}}%
    {\usebibmacro{italtitle+stitle}}}%
  {}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash%
  {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{titleaddon}}%
    {}%
    {\ifboolexpr{%
        togl {cms@related}%
        and
        test {\iffieldequalstr{relatedtype}{commenton}}%
      }%
      {\usebibmacro{related:init}%
        \usebibmacro{related}}%
      {}}}%
  {\ifboolexpr{%
      togl {cms@related}%
      and
      test {\iffieldequalstr{relatedtype}{commenton}}%
    }%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{titleaddon}}%
      {}%
      {\usebibmacro{italtitle+stitle}%
        \newcunit\newblock
        \usebibmacro{date}%
        \usebibmacro{time+stamp}%
        \iftoggle{cms@switchdates}%
        {\clearfield{orighour}\clearfield{origyear}\clearfield{origmonth}%
          \clearfield{origday}\clearfield{origyeardivision}}%
        {\clearfield{hour}\clearfield{year}\clearfield{month}%
          \clearfield{day}\clearfield{yeardivision}}%
        \newunit\newblock}%
      \usebibmacro{related:init}%
      \usebibmacro{related}}%
    {\usebibmacro{italtitle+stitle}}}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \printlist{organization}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newcunit\newblock% 17th ed. comma
  \usebibmacro{date}%
  \usebibmacro{time+stamp}% 17th ed.
  \newunit\newblock
  \printfield{type}%
  \newunit\newblock
  \printfield{addendum}%
  \newunit\newblock
  \ifboolexpr{%
    (
    test {\iffieldundef{urlyear}}%
    and
    test {\iffieldundef{urlmonth}}%
    )
    or
    togl {cms@doinodate}%
  }%
  {}%
  {\printurldate%
    \ifboolexpr{%
      togl {cms@urltime}%
      and
      not test {\iffieldundef{urlhour}}%
    }%
    {\newcunit\printurltime}%
    {}}% Date fix
  \newunit\newblock
  \iftoggle{cms@doionly}%
  {\iffieldundef{doi}%
    {}%
    {\printfield{doi}%
      \clearfield{url}}}%
  {\printfield{doi}}%
  \newunit\newblock%
  \usebibmacro{eprint}%
  \newunit\newblock
  \printfield{url}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldequalstr{relatedtype}{commenton}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{patent}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author+holder}% + holder?
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{patenttitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}[1]%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{patenttitle+stitle}}%
  \setunit{\newunitpunct}%
  \printfield{note}%
  \setunit{\newunitpunct}%
  \usebibmacro{bibreprint}%
  \printfield{type}%
  \setunit{\addspace}%
  \printfield{number}%
  \iflistundef{location}%
    {}%
    {\setunit*{\addspace}%
     \printtext[parens]{%
       \printlist[][-\value{listtotal}]{location}}}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \iftoggle{cms@switchdates}%
  {\bibstring{patentfiled}%
    \setunit{\addspace}%
    \printdate%
    \setunit{\addcomma\addspace}%
    \bibstring{and}%
    \addspace\bibstring{patentissued}\addspace%
    \printorigdate}%
  {\iffieldundef{origyear}%
    {\iffieldundef{year}%
      {}%
      {\bibstring{patentfiled}\setunit{\addspace}%
        \printdate}}%
    {\bibstring{patentfiled}\setunit{\addspace}%
      \printorigdate%\usebibmacro{date}%
      \setunit{\finalandcomma\addspace\bibstring{and}%
        \addspace\bibstring{patentissued}\addspace}%
      \usebibmacro{date}}}%
  \newcunit\newblock
  \printfield{addendum}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \iftoggle{cms@related}%
  {\newunit%
    \usebibmacro{related:init}%
    \usebibmacro{related}}%
  {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{performance}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}%
  {\usebibmacro{italtitle+stitle}}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{howpublished}%
  \newunit\newblock
  \printfield{type}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \printfield{venue}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{institution+organization}%
  \setunit*{\addcomma\addspace}\newblock
  \printlist{location}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{periodical}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{editor}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    and
    not togl {cms@origpublished}%
  }%
  {\ifboolexpr{%
      not test {\iffieldundef{shorttitle}}%
      and
      ((
      togl {cms@bibjtabb}%
      and
      test {\ifbibliography}%
      )
      or
      (
      test {\iffieldundef{title}}%
      and
      test {\iffieldundef{titleaddon}}%
      ))
    }%
    {\clearlist{location}\printtext[shorttitle]{%
        \printfield[tnoformat]{shorttitle}}}%
    {\iffieldundef{title}%
      {\printfield{titleaddon}}%
      {\printtext[title]{%
          \printfield[tnoformat]{title}%
          \setunit{\subtitlepunct}%
          \printfield[stnoformat]{subtitle}}%
        \setunit{\jtitleaddonpunct}%
        \printfield{titleaddon}}}%
    \setunit{\addspace}%
    \printlist[periodplace]{location}%
    \clearlist{location}%
    \clearfield{shorttitle}%
    \clearfield{title}%
    \clearfield{subtitle}%
    \newunit\newblock}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{periodical+date+issue}%
  \newcunit\newblock
  \usebibmacro{chap+pag}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}
{\usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{editor}%
  \newunit\newblock
  \ifboolexpr{%
    test {\ifundef{\bbx@lasthash}}%
    and
    not togl {cms@origpublished}%
  }%
  {\ifboolexpr{%
      not test {\iffieldundef{shorttitle}}%
      and
      ((
      togl {cms@bibjtabb}%
      and
      test {\ifbibliography}%
      )
      or
      (
      test {\iffieldundef{title}}%
      and
      test {\iffieldundef{titleaddon}}%
      ))
    }%
    {\clearlist{location}\printtext[shorttitle]{%
        \printfield[tnoformat]{shorttitle}}}%
    {\iffieldundef{title}%
      {\printfield{titleaddon}}%
      {\printtext[title]{%
          \printfield[tnoformat]{title}%
          \setunit{\subtitlepunct}%
          \printfield[stnoformat]{subtitle}}%
        \setunit{\jtitleaddonpunct}%
        \printfield{titleaddon}}}%
    \setunit*{\addspace}%
    \printlist[periodplace]{location}%
    \clearlist{location}%
    \clearfield{shorttitle}%
    \clearfield{title}%
    \clearfield{subtitle}%
    \newunit\newblock}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit*{\newunitpunct}\newblock% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock% (changed for 0.7)??
  \iftoggle{cms@switchdates}%
  {\usebibmacro{periodical+issue+year+pages}{orig}}%
  {\usebibmacro{periodical+issue+year+pages}{}}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{proceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock
  \ifboolexpr{%
    test {\iffieldundef{crossref}}%
    or
    togl {cms@bookcrossref}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{xref}}%
      or
      togl {cms@bookcrossref}%
    }%
  {\usebibmacro{mtitle+mstitle+vol+part+title+stitle}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{volume+or+volumes}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \printfield{note}%
  \setunit*{\addcomma\addspace}%
  \printfield{eventtitle}%
  \setunit{\ctitleaddonpunct}%
  \printfield{eventtitleaddon}%
  \newcunit%
  \printfield{venue}%
  \newcunit\newblock
  \printeventdate%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{org+publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{xref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}%
{\ifboolexpr{% Changed for 16th ed.
    test {\ifterm}%
    or
    test {\ifpunctmark{*}}%
  }%
  {\setunit{\addspace\bibsentence}}%
  {\setunit{\newunitpunct}}%
  \usebibmacro{bibprexref}%
  \bibxrefcite{\thefield{crossref}}%
  \usebibmacro{bibpostxref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{reference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{reference+title}%{italtitle+stitle}
  \newunit\newblock
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \setunit*{\newunitpunct}% need asterisk?
  \usebibmacro{mtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newcunit\newblock
  \printfield{chapter}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \printfield{type}%
  \newcunit
  \usebibmacro{series+or+shortser}%
  \ifthenelse{\iffieldundef{type}\AND\iffieldundef{series}}%
  {\newunit}%
  {\setunit{\addnbspace}}%
  \printfield{number}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{inst+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isrn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{review}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{mag+news+author}}%
  {\usebibmacro{author/editor}}%
  \newunit\newblock
  \ifundef{\bbx@lasthash}%
  {\ifboolexpr{%
      togl {cms@related}%
      and
      (
      test {\iffieldequalstr{relatedtype}{reviewof}}%
      or
      test {\iffieldequalstr{relatedtype}{commenton}}%
      )
    }%
    {\usebibmacro{related:init}%
      \usebibmacro{related}}%
    {\printfield{title}%
      \setunit{\subtitlepunct}%
      \printfield[noformat]{subtitle}%
      \newunit}}%
  {}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef{\bbx@lasthash}%
  {}%
  {\ifboolexpr{%
      togl {cms@related}%
      and
      (
      test {\iffieldequalstr{relatedtype}{reviewof}}%
      or
      test {\iffieldequalstr{relatedtype}{commenton}}%
      )
    }%
    {\usebibmacro{related:init}%
      \usebibmacro{related}}%
    {\printfield{title}%
      \setunit{\subtitlepunct}%
      \printfield[noformat]{subtitle}}}%
  \setunit{\ptitleaddonpunct}%
  \printfield{titleaddon}%
  \newcunit\newblock
  \usebibmacro{music+eventdate}% 16th ed.
  \newcunit\newblock
  \printeventtime%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock%
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{part+editor+translator}%
  \newunit\newblock%
  \usebibmacro{bibreprint}%
  \usebibmacro{issuetitle}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{byeditor+others}%
  \newunit\newblock% 17th ed.
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{mag+news+date}%
    \newunit\newblock
    \printfield{type}%
    \newcunit\newblock
    \usebibmacro{chap+pag}}%
  {\iftoggle{cms@switchdates}%
    {\usebibmacro{journal+issue+year+pages}{orig}}%
    {\usebibmacro{journal+issue+year+pages}{}}}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldequalstr{relatedtype}{reviewof}}%
    and
    not test {\iffieldequalstr{relatedtype}{commenton}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{standard}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \ifnameundef{author}%
  {\iflistundef{organization}%
    {\let\bbx@lasthash\undefined}%
    {\ifboolexpr{%
        test {\iflistequals{organization}{\bbx@lasthash}}%
        and
        not test {\iffirstonpage}%
        and
        togl {cms@namedash}%
      }%
      {\if@cms@nonameaddon%
        {\printtext{\bibnamedash}}%
        {\printtext{\bibnamedash}\setunit{\nameaddonpunct}%
          \printfield{nameaddon}}}%
      {\iftoggle{cms@authorparens}%
        {\bibopenparen\printlist{organization}%
          \usebibmacro{print+nameaddon}%
          \bibcloseparen}%
        {\printlist{organization}%
          \usebibmacro{print+nameaddon}}%
        \savelist{organization}{\bbx@lasthash}}}}%
  {\usebibmacro{justauthor}}%
  \newunit\newblock
  \ifundef{\bbx@lasthash}{\usebibmacro{italtitle+stitle}}{}%
  \ifthenelse{\iffieldundef{userd}\AND\iffieldundef{howpublished}}%
  {\usebibmacro{cmsbibsortdate}}%
  {\usebibmacro{cmsbibsortdate}[1]}% Like Patent entries (?)
  \newunit\newblock
  \ifundef{\bbx@lasthash}{}%
  {\usebibmacro{italtitle+stitle}}%
  \newunit\newblock
  \usebibmacro{edition}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \usebibmacro{series+or+shortser}%
  \setunit*{\addspace}%
  \printfield{number}%
  \newunit\newblock
  \printfield{type}%
  \newunit
  \printfield{note}%
  \newunit\newblock%
  \usebibmacro{origpubl+loc+year}%{cmsorigdate}% 16th ed.
  \newunit\newblock%
  \usebibmacro{bibreprint}%
  \printlist{location}%
  \iflistundef{publisher}%
  {\iflistundef{organization}%
    {\setunit*{\addcomma\addspace}}%
    {\setunit*{\addcolon\addspace}%
      \printlist{organization}%
      \setunit*{\addcomma\addspace}}}%
  {\setunit*{\addcolon\addspace}%
    \printlist{publisher}%
    \setunit*{\addcomma\addspace}}%
  \usebibmacro{date}
  \setunit{\addsemicolon\addspace}%
  \printfield{howpublished}%
  \setunit*{\addspace}%
  \usebibmacro{music+eventdate}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \ifboolexpr{%
    togl {cms@related}%
    and
    not test {\iffieldundef{related}}%
  }%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{suppbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author}%
  \newunit\newblock
  \ifundef\bbx@lasthash{%
  \usebibmacro{inforaft}%
  \setunit{\addspace}\newblock
  \usebibmacro{italtitle+stitle}%
  \newcunit\newblock
  \usebibmacro{bybookauthor}%
  \clearname{bookauthor}%
  \newunit\newblock}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{%
  \usebibmacro{inforaft}%
  \setunit{\addspace}\newblock
  \usebibmacro{italtitle+stitle}}%
  \newunit
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \newcunit\newblock
  \usebibmacro{chap+pag}%
  \newunit\newblock
  \usebibmacro{mtitle+mstitle+vol+part+title+stitle}%
  \newcunit%
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \usebibmacro{editorpunct}%
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{volume+or+volumes}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{suppcollection}{suppbook}

\DeclareBibliographyAlias{suppperiodical}{review}

\DeclareBibliographyDriver{thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit% 16th ed.
  \usebibmacro{byauthor}%
  \setunit{\newunitpunct}%
  \printfield{note}%
  \setunit{\newunitpunct}\newblock%
  \usebibmacro{bibreprint}%
  \usebibmacro{type+inst+year}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{unpublished}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{\usebibmacro{italtitle+stitle}}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{\usebibmacro{italtitle+stitle}}%
  \newunit%usebibmacro{byauthorpunct}% Why does this work?  No idea.
  \usebibmacro{byauthor}% Same in thesis type, as well. 16th ed.
  \setunit{\newunitpunct}%
  \usebibmacro{byeditor+others}% Fix bug ???
  \newunit\newblock
  \usebibmacro{bibreprint}%
  \printfield{howpublished}%
  \setunit*{\addcomma\addspace}\newblock%
  \printfield{note}%
  \setunit*{\addcomma\addspace}\newblock%
  \printfield{eventtitle}%
  \setunit*{\ctitleaddonpunct}\newblock%
  \printfield{eventtitleaddon}%
  \setunit*{\addcomma\addspace}%
  \printfield{venue}%
  \setunit*{\addcomma\addspace}%
  \printlist{location}%
  \setunit*{\addcomma\addspace}\newblock%
  \iffieldundef{eventmonth}%
  {\usebibmacro{date}}%
  {\printeventdate}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{video}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{shorthand:author}%
  \usebibmacro{author/editor}%
  \newunit\newblock
  \ifundef\bbx@lasthash{%
    \usebibmacro{video+tv+title}%
    \newunit\newblock}{}%
  \usebibmacro{cmsbibsortdate}%
  \newunit\newblock
  \ifundef\bbx@lasthash{}{%
    \usebibmacro{video+tv+title}}%
  \ifboolexpr{%
    test {\iffieldequalstr{entrysubtype}{tvepisode}}%
    and
    (
    not test {\iffieldundef{title}}%
    and
    not test {\iffieldundef{booktitle}}%
    )
  }%
  {\usebibmacro{video+title}%
    \iffieldundef{booktitle}%
    {\setunit{\ctitleaddonpunct}}%
    {\setunit{\ptitleaddonpunct}}%
    \printfield{titleaddon}%
    \setunit{\addspace}\newblock%
    \usebibmacro{language+transtitle}%
    \usebibmacro{byauthor}%
    \setunit{\newunitpunct}%
    \usebibmacro{part+editor+translator}}
  {\setunit{\newunitpunct}% 16th ed.
    \usebibmacro{byauthor}%
    \setunit{\newunitpunct}%
    \usebibmacro{part+editor+translator}%
    \setunit{\newunitpunct}%
    \usebibmacro{chapinscore}%
    \usebibmacro{btitle+bstitle}}%
  \iffieldundef{booktitle}%
  {\setunit{\newunitpunct}}% Fix customc?
  {\setunit{\addcomma\addspace}}%
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newunit% unit, not cunit?
  \usebibmacro{bybookauthor}%
  \usebibmacro{byeditor+others}%
  \newunit% ??? Editorpunct maybe not right here?
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\ifthenelse{\iffieldundef{title}\AND\iffieldundef{booktitle}}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext{%
        \printfield{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}%
    {\printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring[\cms@ofwrap]{ofseries}%
      \iftoggle{smartof}{}{\setunit{\addspace}}%
      \printtext{%
        \printfield[title:hook:alt]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}%
  \newcunit\newblock
  \usebibmacro{volume+pages}%
  \newunit\newblock
  \usebibmacro{ser+num}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{music+eventdate}%
  \setunit*{\addcomma\addspace}%
  \printfield{usera}%
  \newunit\newblock
  \usebibmacro{origpubl+loc+year}% 16th ed.
  \newunit\newblock
  \usebibmacro{bibreprint}% 17th ed.
  \usebibmacro{publ+loc+year}%
  \newunit\newblock
  \printfield{type}%
  \newunit\newblock
  \usebibmacro{pubstate}%
  \newunit\newblock
  \printfield{addendum}%
  \setunit*{\addcomma\addspace}\newblock%
  \iftoggle{cms@isbn}%
  {\printfield{isan}}%
  {}%
  \setunit*{\addcomma\addspace}\newblock%
  \usebibmacro{bib+doi+url}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{cms@related}%
  {\usebibmacro{related:init}%
    \usebibmacro{related}%
    \newunit}%
  {}%
  \usebibmacro{originally+published+as}%
  \usebibmacro{finentry}}%

%%%% Other Formatting Macros %%%%

\newbibmacro*{bib+doi+url}{% 16th ed.
  \ifboolexpr{%
    not togl {cms@url}%
    or
    (
    test {\iffieldundef{urlyear}}%
    and
    test {\iffieldundef{urlmonth}}%
    )
    or
    togl {cms@doinodate}%
  }%
  {}%
  {\printurldate%
    \ifboolexpr{%
      togl {cms@urltime}%
      and
      not test {\iffieldundef{urlhour}}%
    }%
    {\newcunit\printurltime}%
    {}}% Date fix
  \iffieldundef{addendum}%
  {\newunit\newblock}%
  {\newcunit\newblock}%
  \iftoggle{cms@doionly}%
  {\iffieldundef{doi}%
    {}%
    {\printfield{doi}%
      \setunit*{\newunitpunct}\newblock%
      \clearfield{url}}}%
  {\ifboolexpr{%
      togl {cms@doi}%
      and
      not test {\iffieldundef{doi}}%
    }%
    {\printfield{doi}%
      \setunit*{\newunitpunct}\newblock}%
    {}}%
  \ifboolexpr{%
    togl {cms@eprint}%
    and
    not test {\iffieldundef{eprint}}%
  }%
  {\usebibmacro{eprint}%
    \setunit*{\newunitpunct}\newblock}%
  {}%
  \ifboolexpr{%
    togl {cms@url}%
    and
    not test {\iffieldundef{url}}%
  }%
  {\printfield{url}}%
  {}}%

\newbibmacro*{shorthand:author}{%
  \ifboolexpr{%
    test {\iffieldundef{shorthand}}%
    or
    not togl {cms@los}%
  }%
  {\togglefalse{cms@authorparens}%
    \global\csundef{cms@shauthor}}%
  {\ifboolexpr{%
      ((
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      or
      test {\iffieldequals{shorthand}{\cms@shauthor}}%
      )
      and
      togl {cms@namedash}%
      )
      and
      not test {\iffirstonpage}%
    }%
    {\togglefalse{cms@authorparens}}%
    {\toggletrue{cms@authorparens}%
      \savefield{shorthand}{\cms@shauthor}%
      \printfield{shorthand}\addspace}}}

\newbibmacro*{shorthand:label}{% Test this
  \ifthenelse{\iffieldequalstr{entrysubtype}{magazine}\AND\NOT%
    \ifentrytype{periodical}}% Simplifies .bib creation
    {\printfield[journaltitle]{journaltitle}}%
    {\ifthenelse{\ifentrytype{manual}\OR\ifentrytype{standard}}%
      {\printlist{organization}}%
      {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{review}\OR%
          \ifentrytype{suppperiodical}}%
          {\iffieldundef{shorttitle}% Authorless articles w/o subtype
            {\printfield[citetitle]{title}}%
            {\printfield[citetitle]{shorttitle}}}%
          {\printfield[citetitle]{labeltitle}}}}}%

\newbibmacro*{labelyear+extrayear}{%
  \ifboolexpr{ (
    test {\ifentrytype{music}}%
    or
    test {\ifentrytype{review}}%
    or
    test {\ifentrytype{standard}}%
    or
    test {\ifentrytype{suppperiodical}}%
    or
    test {\ifentrytype{video}}%
    )
    and
    togl {cms@avdate}%
  }%
  {\usebibmacro{av+labelyear+extrayear}}%
  {\iftoggle{cms@ordate}%
    {\usebibmacro{origfirst+labelyear+extrayear}}%
    {\usebibmacro{standard+labelyear+extrayear}}}}

\protected\def\cmsunspecified#1#2{%
  \ifboolexpr{%
    test {\iffieldundef{#2dateunspecified}}%
    or
    togl {cms@alwaysrange}%
  }%
  {\ifboolexpr{%
      test {\iffieldundef{#2endyear}}%
      or
      test {\iffieldequalstr{#2dateera}{bce}}%
      or
      not togl {cms@compyears}%
      or
      not test {\iffieldnum{#2year}}%
      or
      not test {\iffieldnum{#2endyear}}%
      or
      not test {\if@cms@onlyyears{#2}}%
    }%
    {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}\cmsdateeraprint{#2year}}%
    {\cmscompcenturies{#2}%
      \ifboolexpr{%
        (
        test {\if@cms@bracket}%
        and
        not test {\if@cms@endbracket}
        )
        or
        (
        not test {\if@cms@bracket}%
        and
        test {\if@cms@endbracket}%
        )
        or
        (
        test {\if@cms@endcirca}%
        and
        not test {\if@cms@circa}%
        )
        or
        not test {\ifnumequal{\cms@tempcnta}{\cms@tempcntb}}%
      }%
      {\csuse{mkbibdate#1}{#2year}{}{}\cmsdateeraprint{#2year}}%
      {\cmsdateeraprintpre{#2year}\cmscompressyears{#2}%
        \cmsdateeraprint{#2endyear}\clearfield{#2endyear}}}}%
  {\ifboolexpr{%
      test {\iffieldequalstr{#2dateunspecified}{yearindecade}}%
      and
      test {\ifbibstring{decade}}%
      and
      not togl {cms@decaderange}%
    }%
    {\cmsmkdecade{#1}{#2}}%
    {\ifboolexpr{%
        test {\iffieldequalstr{#2dateunspecified}{yearincentury}}%
        and
        test {\ifbibstring{century}}%
        and
        not togl {cms@centuryrange}%
      }%
      {\cmsmkcentury{#2}}%
      {\iftoggle{cms@compyears}%
        {\cmsdateeraprintpre{#2year}\cmscompressyears{#2}%
          \cmsdateeraprint{#2endyear}\clearfield{#2endyear}}%
        {\csuse{mkbibdate#1}{#2year}{}{}\cmsdateeraprint{#2year}}}}}}%

\protected\def\cmscompressyears#1{%
  \def\cms@tempa{\thefield{#1year}--\thefield{#1endyear}}%
  \edef\cms@tempb{\mkcomprange{\csuse{cms@tempa}}}%
  \cms@tempb}%

\newcount\cms@tempcnta
\newcount\cms@tempcntb

\def\cmscompcenturies#1{%
  \cms@tempcnta=\thefield{#1year}%
  \divide\cms@tempcnta100
  \cms@tempcntb=\thefield{#1endyear}%
  \divide\cms@tempcntb100}

\protected\def\cmsformatextra{%
  \ifboolexpr{%
    test {\if@cms@bracket}%
    and
    not togl {cms@noyearbrackets}%
  }%
  {\usebibmacro{cmsextradate}%
    \global\boolfalse{cms:extraparens}}%
  {\ifbool{cms:extraparens}%
    {\usebibmacro{cmsparensextradate}%
      \global\boolfalse{cms:extraparens}}%
    {\usebibmacro{cmsextradate}}}}

\protected\def\cmsformatendextra{%
  \ifboolexpr{%
    test {\if@cms@endbracket}%
    and
    test {\if@cms@bracket}%
    and
    not togl {cms@noyearbrackets}%
  }%
  {\usebibmacro{cmsextradate}%
    \global\boolfalse{cms:extraparens}}%
  {\ifbool{cms:extraparens}%
    {\usebibmacro{cmsparensextradate}%
      \global\boolfalse{cms:extraparens}}%
    {\usebibmacro{cmsextradate}}}}

\newbibmacro*{cmsextradate}{% For use with some date specs
  \iffieldundef{extradate}%
  {\ifboolexpr{% For authorless articles in newspapers & magazines
      not test {\iffieldundef{extratitleyear}}%
      and
      (
      test {\ifentrytype{article}}%
      or
      test {\ifentrytype{review}}%
      or
      test {\ifentrytype{suppperiodical}}%
      )
      and
      test {\iffieldequalstr{entrysubtype}{magazine}}%
      and
      test {\ifnameundef{labelname}}%
    }%
    {\setunit*{}%
      \printfield{extratitleyear}\clearfield{extratitleyear}}%
    {}}%
  {\setunit*{}%
    \printfield{extradate}\clearfield{extradate}}}

\newbibmacro*{cmsparensextradate}{% For use with other date specs
  \iffieldundef{extradate}%
  {\ifboolexpr{% For authorless articles in newspapers & magazines
      not test {\iffieldundef{extratitleyear}}%
      and
      (
      test {\ifentrytype{article}}%
      or
      test {\ifentrytype{review}}%
      or
      test {\ifentrytype{suppperiodical}}%
      )
      and
      test {\iffieldequalstr{entrysubtype}{magazine}}%
      and
      test {\ifnameundef{labelname}}%
    }%
    {\setunit*{}%
      \mkbibparens{\printfield{extratitleyear}}\clearfield{extratitleyear}}%
    {}}%
  {\setunit*{}%
    \mkbibparens{\printfield{extradate}}\clearfield{extradate}}}

\protected\def\cmsdateeraprintpre#1{% AD/BC order depends on language
  \ifdefstring\blx@dateera{astronomical}%
  {\iffieldnum{#1}%
    {\begingroup%
      \let\blx@tempa\@empty%
      \blx@ifstrendswith{#1}{endyear}%
      {\blx@stripfromendinto{#1}{endyear}\blx@datetype%
        \def\blx@tempa{end}}%
      {\blx@stripfromendinto{#1}{year}\blx@datetype}%
      \csuse{if\blx@datetype\blx@tempa dateera}{bce}%
      {\ifnumless{0-\thefield{#1}}{0}%
        {\printtext{\csuse{bibdateera\blx@tempa prefix}}}%
        {}}%
      {}%
      \endgroup}%
    {}}%
  {\ifboolexpr{%
      test {\ifdefstring\blx@dateera{christian}}%
      and
      test {\if@cms@adfirst}%
    }%
    {\iffieldnum{#1}%
      {\begingroup%
        \let\blx@tempa\@empty%
        \blx@ifstrendswith{#1}{endyear}%
        {\blx@stripfromendinto{#1}{endyear}\blx@datetype%
          \def\blx@tempa{end}}%
        {\blx@stripfromendinto{#1}{year}\blx@datetype}%
        \csuse{if\blx@datetype\blx@tempa dateera}{bce}%
        {\ifdefstring\blx@tempa{end}{}{\global\toggletrue{cms@bc}}}%
        {\ifnumless{\thefield{#1}}\blx@dateeraauto%
          {\ifdefstring\blx@tempa{end}%
            {\iftoggle{cms@bc}%
              {\printtext{%
                  \bibsstring{\blx@dateera@ce}\printdelim{dateaddelim}}%
                \global\togglefalse{cms@bc}}%
              {}}%
            {\printtext{%
                \bibsstring{\blx@dateera@ce}\printdelim{dateaddelim}}%
              \global\togglefalse{cms@bc}}}%
          {}}%
        \endgroup}%
      {}}%
    {}}}

\protected\def\cmsdateeraprint#1{% AD/BC order depends on language
  \ifboolexpr{%
    test {\ifdefstring\blx@dateera{christian}}%
    and
    test {\if@cms@adfirst}%
  }%
  {\iffieldnum{#1}
    {\begingroup
      \let\blx@tempa\@empty
      \blx@ifstrendswith{#1}{endyear}
      {\blx@stripfromendinto{#1}{endyear}\blx@datetype
        \def\blx@tempa{end}}
      {\blx@stripfromendinto{#1}{year}\blx@datetype}%
      \csuse{if\blx@datetype\blx@tempa dateera}{bce}%
      {\ifdefstring\blx@tempa{end}%
        {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto%
          \printtext{\printdelim{dateeradelim}\midsentence%
            \bibsstring{\blx@dateera@bce}}%
          \global\booltrue{cms:extraparens}\relax%
          \fi}%
        {\csuse{if\blx@datetype enddateera}{bce}%
          {}%
          {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto%
            \printtext{\printdelim{dateeradelim}\midsentence%
              \bibsstring{\blx@dateera@bce}}%
            \global\booltrue{cms:extraparens}\relax%
            \fi}}}%
      {}%
      \endgroup}
    {}}%
  {\ifboolexpr{%
      test {\ifdefstring\blx@dateera{secular}}%
      or
      (
      test {\ifdefstring\blx@dateera{christian}}%
      and
      not test {\if@cms@adfirst}%
      )
    }%
    {\iffieldnum{#1}%
      {\begingroup%
        \let\blx@tempa\@empty%
        \blx@ifstrendswith{#1}{endyear}%
        {\blx@stripfromendinto{#1}{endyear}\blx@datetype%
          \def\blx@tempa{end}}%
        {\blx@stripfromendinto{#1}{year}\blx@datetype}%
        \csuse{if\blx@datetype\blx@tempa dateera}{bce}%
        {\ifdefstring\blx@tempa{end}%
          {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto%
            \printtext{\printdelim{dateeradelim}\midsentence%
              \bibsstring{\blx@dateera@bce}}%
            \global\booltrue{cms:extraparens}\relax%
            \fi}%
          {\csuse{if\blx@datetype enddateera}{bce}%
            {}%
            {\ifnum\numexpr0-\thefield{#1}\relax<\blx@dateeraauto%
              \printtext{\printdelim{dateeradelim}\midsentence%
                \bibsstring{\blx@dateera@bce}}%
              \global\booltrue{cms:extraparens}\relax%
              \fi}}}%
        {\ifdefstring\blx@tempa{end}%
          {\ifnumless{\thefield{#1}}\blx@dateeraauto%
            {\printtext{\printdelim{dateeradelim}\midsentence%
                \bibsstring{\blx@dateera@ce}}%
              \global\booltrue{cms:extraparens}}%
            {}}%
          {\csuse{if\blx@datetype enddateera}{ce}%
            {}%
            {\ifnumless{\thefield{#1}}\blx@dateeraauto%
              {\printtext{\printdelim{dateeradelim}\midsentence%
                  \bibsstring{\blx@dateera@ce}}%
                \global\booltrue{cms:extraparens}}%
              {}}}}%
        \endgroup}%
      {}}%
    {}}}

\newrobustcmd*{\cms@datebrackets}{%
  \iftoggle{cms@nodatebrackets}%
  {\global\boolfalse{cms:bracket}}%
  {\global\booltrue{cms:bracket}%
    \bibopenbracket}}%

\newrobustcmd*{\cms@yearbrackets}{%
  \iftoggle{cms@noyearbrackets}%
  {\global\boolfalse{cms:bracket}}%
  {\global\booltrue{cms:bracket}%
    \bibopenbracket}}%

\newrobustcmd*{\cms@mkbibrangetrunc}[2]{% DATE FIX
  \begingroup
  \blx@metadateinfo{#2}%
  \clearfield{extradate}\clearfield{extratitleyear}%
  \ifthenelse{\iffieldundef{#2year}\AND\iffieldundef{#2month}\AND%
    \iffieldundef{#2yeardivision}}%
  {}%
  {\printtext[#2date]{%
      \if@cms@bracket%
      {\cms@datebrackets%
        \if@cms@circa%
        {\bibsstring{circa}\printdelim{datecircadelim}}%
        {}}%
      {\global\boolfalse{cms:bracket}}%
      \iffieldundef{#2yeardivision}%
      {\ifdateyearsequal{#2}{#2end}%
        {\iffieldsequal{#2month}{#2endmonth}%
          {\csuse{mkbibdate#1}{}{}{#2day}}%
          {\ifthenelse{\iffieldundef{#2month}\AND\iffieldundef{#2day}}%
            {\csuse{mkbibdate#1}{#2year}{}{}\cmsdateeraprint{#2endyear}%
              \clearfield{#2endyear}}% Clear up inheritance problem ???
            {\csuse{mkbibdate#1}{}{#2month}{#2day}}}}%
        {\cmsunspecified{#1}{#2}}}%
      {\ifdateyearsequal{#2}{#2end}%
        {\ifthenelse{\iffieldundef{#2endyeardivision}\OR%
            \iffieldsequal{#2yeardivision}{#2endyeardivision}}%
          {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}%
            \cmsdateeraprint{#2endyear}\clearfield{#2endyear}}%
          {\csuse{mkbibyeardivisiondate#1}{}{#2yeardivision}}}%
        {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}%
          \cmsdateeraprint{#2year}}}%
      \if@cms@bracket%
      {\if@cms@uncertain%
        {\if@cms@enduncertain%
          {\iffieldundef{#2endyear}%
            {\bibdateuncertain}%
            {}}%
          {\bibdateuncertain}}%
        {\if@cms@enduncertain%
          {\iffieldundef{#2endyear}%
            {\bibdateuncertain}%
            {}}%
          {}}}%
      {}%
      \iffieldundef{#2endyear}%
      {\iffieldundef{#2endmonth}%
        {\ifthenelse{\iffieldundef{#2endyeardivision}\OR%
            \iffieldsequal{#2yeardivision}{#2endyeardivision}}%
          {\ifbool{cms:bracket}%
            {\bibclosebracket\global\boolfalse{cms:bracket}}%
            {}}%
          {\bibdaterangesep%
            \csuse{mkbibyeardivisiondate#1}{}{#2endyeardivision}}}%
        {\bibdaterangesep%
          \csuse{mkbibdate#1}{}{#2endmonth}{#2endday}}}%
      {\iffieldequalstr{#2endyear}{}%
        {\ifbool{cms:bracket}%
          {\bibclosebracket\global\boolfalse{cms:bracket}}%
          {}%
          \mbox{\bibdaterangesep}}%
        {\ifbool{cms:bracket}%
          {\if@cms@circa%
            {\if@cms@endbracket%
              {\bibdaterangesep}%
              {\bibclosebracket\global\boolfalse{cms:bracket}%
                \bibdaterangesep}}%
            {\if@cms@endcirca%
              {\bibdaterangesep\bibsstring{circa}\printdelim{datecircadelim}}%
              {\if@cms@enduncertain%
                {\bibdaterangesep}%
                {\bibclosebracket\global\boolfalse{cms:bracket}%
                  \bibdaterangesep}}}}%
          {\if@cms@endbracket%
            {\bibdaterangesep%
              \cms@datebrackets%
              \if@cms@endcirca%
              {\if@cms@circa%
                {}%
                {\bibsstring{circa}\printdelim{datecircadelim}}}%
              {}}%
            {\bibdaterangesep}}%\bibdatedash%
          \iffieldundef{#2endyeardivision}%
          {\ifdateyearsequal{#2}{#2end}%
            {\csuse{mkbibdate#1}{#2year}{#2endmonth}{#2endday}}%
            {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}}%
          {\ifdateyearsequal{#2}{#2end}%
            {\csuse{mkbibyeardivisiondate#1}{#2year}{#2endyeardivision}}%
            {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}}%
          \ifbool{cms:bracket}%
          {\if@cms@bracket%
            {\cmsdateeraprint{#2endyear}%
              \enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}}%
            {\enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}%
              \cmsdateeraprint{#2endyear}}}%
          {\enddateuncertainprint%
            \cmsdateeraprint{#2endyear}}}}}}%
  \endgroup}

\newrobustcmd*{\cms@mkbibrangefull}[2]{%
  \begingroup
  \blx@metadateinfo{#2}%
  \clearfield{extradate}\clearfield{extratitleyear}%
  \ifthenelse{\iffieldundef{#2year}\AND\iffieldundef{#2month}\AND%
    \iffieldundef{#2yeardivision}}%
  {}%
  {\printtext[#2date]{%
      \if@cms@bracket%
      {\cms@datebrackets%
        \if@cms@circa%
        {\bibsstring{circa}\printdelim{datecircadelim}}
        {}}%
      {\global\boolfalse{cms:bracket}}%
      \iffieldundef{#2yeardivision}%
      {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
        \ifboolexpr{%
          test {\ifdateyearsequal{#2}{#2end}}%
          and
          test {\iffieldundef{#2month}}%
          and
          test {\iffieldundef{#2day}}%
        }%
        {\cmsdateeraprint{#2endyear}\clearfield{#2endyear}}%
        {\cmsdateeraprint{#2year}}}%
      {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}%
        \cmsdateeraprint{#2year}}%
      \if@cms@bracket%
      {\if@cms@uncertain%
        {\if@cms@enduncertain%
          {\iffieldundef{#2endyear}%
            {\bibdateuncertain}%
            {}}%
          {\bibdateuncertain}}%
        {\if@cms@enduncertain%
          {\iffieldundef{#2endyear}%
            {\bibdateuncertain}%
            {}}%
          {}}}%
      {}%
      \ifthenelse{\iffieldundef{#2endyear}\AND\iffieldundef{#2endmonth}%
        \AND\iffieldundef{#2endyeardivision}}%
      {\ifbool{cms:bracket}%
        {\bibclosebracket\global\boolfalse{cms:bracket}}%
        {}}%
      {\iffieldequalstr{#2endyear}{}%
        {\ifbool{cms:bracket}%
          {\bibclosebracket\global\boolfalse{cms:bracket}}%
          {}%
          \mbox{\bibdaterangesep}}%
        {\ifbool{cms:bracket}%
          {\if@cms@circa%
            {\if@cms@endbracket%
              {\bibdaterangesep}%
              {\bibclosebracket\global\boolfalse{cms:bracket}%
                \bibdaterangesep}}%
            {\if@cms@endcirca%
              {\bibdaterangesep\bibsstring{circa}\printdelim{datecircadelim}}%
              {\if@cms@enduncertain%
                {\bibdaterangesep}%
                {\bibclosebracket\global\boolfalse{cms:bracket}%
                  \bibdaterangesep}}}}%
          {\if@cms@endbracket%
            {\bibdaterangesep%
              \cms@datebrackets%
              \if@cms@endcirca%
              {\if@cms@circa%
                {}%
                {\bibsstring{circa}\printdelim{datecircadelim}}}%
              {}}%
            {\bibdaterangesep}}%\bibdaterangesep%
          \iffieldundef{#2endyeardivision}%
          {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}%
          {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}%
          \ifbool{cms:bracket}%
          {\if@cms@bracket%
            {\cmsdateeraprint{#2endyear}%
              \enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}}%
            {\enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}%
              \cmsdateeraprint{#2endyear}}}%
          {\enddateuncertainprint%
            \cmsdateeraprint{#2endyear}}}}}}%
  \endgroup}

\newrobustcmd*{\cms@mkyearrangeextra}[3][]{%
  \global\boolfalse{cms:extraparens}%
  \begingroup
  \clearfield{#3month}\clearfield{#3day}\clearfield{#3endmonth}%
  \clearfield{#3endday}\clearfield{#3yeardivision}%
  \clearfield{#3endyeardivision}%
  \blx@metadateinfo{#3}%
  \iffieldundef{#3year}
  {\blx@nounit}%
  {\printtext{%
      \if@cms@bracket%
      {\cms@yearbrackets%
        \if@cms@circa%
        {\bibsstring{circa}\printdelim{datecircadelim}}
        {}}%
      {\global\boolfalse{cms:bracket}}%
      \ifdateyearsequal{#3}{#3end}%
      {\csuse{mkbibdate#2}{#3year}{}{}\cmsdateeraprint{#3endyear}%
        \clearfield{#3endyear}}%
      {\ifblank{#1}%
        {\cmsunspecified{#2}{#3}}%
        {\csuse{mkbibdate#2}{#3year}{}{}\cmsdateeraprint{#3year}}}%
      \if@cms@bracket%
      {\if@cms@uncertain%
        {\if@cms@enduncertain%
          {\iffieldundef{#3endyear}%
            {\global\booltrue{cms:extraparens}%
              \bibdateuncertain}%
            {}}%
          {\ifthenelse{\iffieldundef{#3endyear}\OR%
              \iffieldequalstr{#3endyear}{}}%
            {\global\booltrue{cms:extraparens}}%
            {}%
            \bibdateuncertain}}%
        {\if@cms@enduncertain%
          {\iffieldundef{#3endyear}%
            {\global\booltrue{cms:extraparens}%
              \bibdateuncertain}%
            {}}%
          {}}}%
      {}%
      \iffieldundef{#3endyear}
      {\ifbool{cms:bracket}%
        {\bibclosebracket\global\boolfalse{cms:bracket}}%
        {}%
        \cmsformatextra}%\usebibmacro{cmsextradate}%
      {\iffieldequalstr{#3endyear}{}%
        {\ifbool{cms:bracket}%
          {\bibclosebracket\global\boolfalse{cms:bracket}}%
          {}%
          \cmsformatextra%\usebibmacro{cmsextradate}%
          \mbox{\bibdaterangesep}}%
        {\ifbool{cms:bracket}%
          {\if@cms@circa%
            {\if@cms@endbracket%
              {\bibdaterangesep}%
              {\bibclosebracket\global\boolfalse{cms:bracket}%
                \bibdaterangesep}}%
            {\if@cms@endcirca%
              {\bibdaterangesep\bibsstring{circa}\printdelim{datecircadelim}}%
              {\if@cms@enduncertain%
                {\bibdaterangesep}%
                {\bibclosebracket\global\boolfalse{cms:bracket}%
                  \bibdaterangesep}}}}%
          {\if@cms@endbracket%
            {\bibdaterangesep%
              \cms@yearbrackets%
              \if@cms@endcirca%
              {\if@cms@circa%
                {}%
                {\bibsstring{circa}\printdelim{datecircadelim}}}%
              {}}%
            {\bibdaterangesep}}%
          \csuse{mkbibdate#2}{#3endyear}{}{}%
          \ifbool{cms:bracket}%
          {\if@cms@bracket%
            {\cmsdateeraprint{#3endyear}%
              \enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}}%
            {\enddateuncertainprint%
              \bibclosebracket\global\boolfalse{cms:bracket}%
              \cmsdateeraprint{#3endyear}}}%
          {\if@cms@enduncertain%
            {\global\booltrue{cms:extraparens}%
              \bibdateuncertain}%
            {}%
            \cmsdateeraprint{#3endyear}}%
          \cmsformatendextra}}}}%
  \endgroup}%

\def\if@cms@adfirst{%
  \ifboolexpr{%
    test {\ifdefstring\blx@languagename{american}}%
    or
    test {\ifdefstring\blx@languagename{british}}%
    or
    test {\ifdefstring\blx@languagename{canadian}}%
    or
    test {\ifdefstring\blx@languagename{english}}%
    or
    test {\ifdefstring\blx@languagename{UKenglish}}%
    or
    test {\ifdefstring\blx@languagename{USenglish}}%
    or
    test {\ifdefstring\blx@languagename{australian}}%
    or
    test {\ifdefstring\blx@languagename{newzealand}}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@bracket{%
  \ifboolexpr{%
    (
    test {\ifdatecirca}%
    and
    togl {blx@datecirca}%
    )
    or
    (
    test {\ifdateuncertain}%
    and
    togl {blx@dateuncertain}%
    )
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@endbracket{%
  \ifboolexpr{%
    (
    test {\ifenddatecirca}%
    and
    togl {blx@datecirca}%
    )
    or
    (
    test {\ifenddateuncertain}%
    and
    togl {blx@dateuncertain}%
    )
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@circa{%
  \ifboolexpr{%
    test {\ifdatecirca}%
    and
    togl {blx@datecirca}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@uncertain{%
  \ifboolexpr{%
    test {\ifdateuncertain}%
    and
    togl {blx@dateuncertain}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@endcirca{%
  \ifboolexpr{%
    test {\ifenddatecirca}%
    and
    togl {blx@datecirca}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@enduncertain{%
  \ifboolexpr{%
    test {\ifenddateuncertain}%
    and
    togl {blx@dateuncertain}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\def\if@cms@onlyyears#1{%
  \ifboolexpr{%
    test {\iffieldundef{#1month}}%
    and
    test {\iffieldundef{#1endmonth}}%
    and
    test {\iffieldundef{#1day}}%
    and
    test {\iffieldundef{#1endday}}%
  }%
  {\@firstoftwo}%
  {\@secondoftwo}}

\newbibmacro*{standard+labelyear+extrayear}{%
  \ifthenelse{\iffieldundef{labelyear}\OR%
    \iffieldequalstr{labelyear}{nodate}}% or new declaration ???
    {\iftoggle{cms@nodates}%
      {\bibstring{nodate}}%
      {}}%
    {\iffieldundef{year}%
      {\iffieldundef{eventyear}%
        {\iffieldundef{origyear}%
          {\iffieldundef{userd}%
            {\iftoggle{cms@nodates}%
              {\bibstring{nodate}}%
              {}}%
            {\printurldateextra%
              \usebibmacro{clear+datefield}{url}}}%
          {\printorigdateextra%
            \usebibmacro{clear+datefield}{orig}}}%
        {\printeventdateextra%
          \usebibmacro{clear+datefield}{event}}}%
      {\printdateextra%
        \usebibmacro{clear+datefield}{}}}}%

\newbibmacro*{origfirst+labelyear+extrayear}{%
  \ifthenelse{\iffieldundef{labelyear}\OR%
    \iffieldequalstr{labelyear}{nodate}}%
    {\iftoggle{cms@nodates}%
      {\bibstring{nodate}}%
      {}}%
    {\iffieldundef{origyear}%
      {\iffieldundef{year}%
        {\iffieldundef{eventyear}%
          {\iffieldundef{userd}%
            {\iftoggle{cms@nodates}%
              {\bibstring{nodate}}%
              {}}%
            {\printurldateextra%
              \usebibmacro{clear+datefield}{url}}}%
          {\printeventdateextra%
            \usebibmacro{clear+datefield}{event}}}%
        {\printdateextra%
          \usebibmacro{clear+datefield}{}}}%
      {\printorigdateextra%
        \usebibmacro{clear+datefield}{orig}}}}%

\newbibmacro*{av+labelyear+extrayear}{%
  \ifthenelse{\iffieldundef{labelyear}\OR%
    \iffieldequalstr{labelyear}{nodate}}%
    {\iftoggle{cms@nodates}%
      {\bibstring{nodate}}%
      {}}%
    {\iffieldundef{eventyear}%
      {\iffieldundef{origyear}%
        {\iffieldundef{year}%
          {\iffieldundef{userd}%
            {\iftoggle{cms@nodates}%
              {\bibstring{nodate}}%
              {}}%
            {\printurldateextra%
              \usebibmacro{clear+datefield}{url}}}%
          {\printdateextra%
            \usebibmacro{clear+datefield}{}}}%
        {\printorigdateextra%
          \usebibmacro{clear+datefield}{orig}}}%
      {\printeventdateextra%
        \usebibmacro{clear+datefield}{event}}}}%

\newbibmacro{artwork+dates}{% 17th ed.
  \iftoggle{cms@ordate}%
  {\IfBeginWith{\thefield{labeldatesource}}{orig}%
    {\iftoggle{cms@switchdates}%
      {\printdate\newunit\printorigdate}%
      {\ifthenelse{\iffieldundef{origmonth}\AND%
          \iffieldundef{origyeardivision}}%
        {\iffieldundef{year}{}{\printdate}}%
        {\printorigdate%
          \iffieldundef{year}%
          {}%
          {\newunit\printdate}}}}%
    {\IfBeginWith{\thefield{labeldatesource}}{event}%
      {}%
      {\ifthenelse{\iffieldundef{month}\AND\iffieldundef{yeardivision}}%
        {}{\printdate}}}}%
  {\ifboolexpr{%
      togl {cms@origlabel}%
      or
      togl {cms@bothlabelold}%
      or
      togl {cms@bothlabelnew}%
    }%
    {\iftoggle{cms@switchdates}%
      {\ifthenelse{\iffieldundef{month}\AND\iffieldundef{yeardivision}}%
        {\printorigdate}%
        {\printdate\newunit\printorigdate}}%
      {\ifthenelse{\iffieldundef{origmonth}\AND%
          \iffieldundef{origyeardivision}}%
        {\printdate}%
        {\printorigdate\newunit\printdate}}}%
    {\iftoggle{cms@switchdates}%
      {\ifthenelse{\iffieldundef{month}\AND\iffieldundef{yeardivision}}%
        {\printorigdate}%
        {\printdate\newunit\printorigdate}}%
      {\iffieldundef{origyear}%
        {\ifthenelse{\iffieldundef{month}\AND\iffieldundef{yeardivision}}%
          {}%
          {\printdate}}%
        {\printorigdate%
          \iffieldundef{year}%
          {}%
          {\newunit\printdate}}}}}}

\newbibmacro*{clear+datefield}[1]{%
  \iftoggle{cms@leaveit}%
  {}%
  {\iffieldundef{#1day}%
    {\iffieldundef{#1endyear}%
      {\clearfield{#1year}}%
      {\ifthenelse{\iffieldundef{#1month}\AND\iffieldundef{#1yeardivision}}%
        {\clearfield{#1year}}%
        {\ifdateyearsequal{#1}{#1end}%
          {\clearfield{#1year}\clearfield{#1endyear}}%
          {}}}}%
    {}}}

\newbibmacro*{cmsbibsortdate}[1][]{% Attempt to solve date-related problems
  \ifblank{#1}{\togglefalse{cms@leaveit}}{\toggletrue{cms@leaveit}}%
  \ifboolexpr{%
    test {\iffieldundef{origyear}}%
    or
    not test {\iffieldint{origyear}}%
  }%
  {\usebibmacro{cmsbibyear}}%
  {\iffieldint{year}%
    {\ifboolexpr{% Needed for date ranges - video type, esp.
        test {\iffieldundef{endyear}}%
        or
        not test {\iffieldnum{endyear}}%
      }%
      {\ifthenelse{\thefield{origyear}>\thefield{year}}%
        {\toggletrue{cms@switchdates}%
          \usebibmacro{cmsbibyear}}%
        {\usebibmacro{cmsbibyear}}}%
      {\ifthenelse{\thefield{origyear}>\thefield{endyear}}%
        {\toggletrue{cms@switchdates}%
          \usebibmacro{cmsbibyear}}%
        {\usebibmacro{cmsbibyear}}}}%
    {\usebibmacro{cmsbibyear}}}}%

\newbibmacro*{cmsbibyear}{%
  \iftoggle{cms@origlabel}%
  {\usebibmacro{origyear+labelyear}}%
  {\iftoggle{cms@bothlabelnew}%
    {\usebibmacro{bothyear+oldstyle}}%
    {\iftoggle{cms@bothlabelold}%
      {\usebibmacro{bothyear+oldstyle}}%
      {\usebibmacro{labelyear+extrayear}}}}}%
  % \ifcsdef{@cms@tempdate}%
  % {\toggletrue{\@cms@tempdate}}%
  % {}}%

\newbibmacro*{origyear+labelyear}{%
  \ifboolexpr{ (
    test {\ifentrytype{music}}%
    or
    test {\ifentrytype{review}}%
    or
    test {\ifentrytype{standard}}%
    or
    test {\ifentrytype{suppperiodical}}%
    or
    test {\ifentrytype{video}}%
    )
    and
    togl {cms@avdate}%
  }%
  {\usebibmacro{av+labelyear+extrayear}}%
  {\iftoggle{cms@switchdates}%
    {\usebibmacro{labelyear+extrayear}}%
    {\iffieldundef{origyear}%
      {\iftoggle{cms@ordate}% ???
        {}%
        {\clearfield{extradate}\clearfield{extratitleyear}}%
        \usebibmacro{standard+labelyear+extrayear}}%
      {\iftoggle{cms@ordate}%
        {\usebibmacro{origfirst+labelyear+extrayear}}%
        {\clearfield{extradate}\clearfield{extratitleyear}%
          \printorigdateextra%\usebibmacro{origyear+endyear}%
          \usebibmacro{clear+datefield}{orig}}}}}}%

\newbibmacro*{bothyear+oldstyle}{%
  \ifboolexpr{ (
    test {\ifentrytype{music}}%
    or
    test {\ifentrytype{review}}%
    or
    test {\ifentrytype{standard}}%
    or
    test {\ifentrytype{suppperiodical}}%
    or
    test {\ifentrytype{video}}%
    )
    and
    togl {cms@avdate}%
  }%
  {\usebibmacro{av+labelyear+extrayear}}% \clearfield local to \printtext
  {\iftoggle{cms@switchdates}%
    {\printtext{%
        \bibopenparen%
        \usebibmacro{labelyear+extrayear}%
        \bibcloseparen%
        \setunit{\addspace}%
        \clearfield{extrayear}%
        \printorigdateextra}% \usebibmacro{origyear+endyear}
      \usebibmacro{clear+datefield}{}%
      \usebibmacro{clear+datefield}{orig}}%
    {\iffieldundef{origyear}%
      {\iftoggle{cms@ordate}%
        {}%
        {\clearfield{extradate}\clearfield{extratitleyear}}%
        \usebibmacro{standard+labelyear+extrayear}}%
      {\iftoggle{cms@ordate}% ???
        {\iffieldundef{year}%
          {\usebibmacro{origfirst+labelyear+extrayear}}%
          {\printtext{%
              \bibopenparen%
              \usebibmacro{origfirst+labelyear+extrayear}%
              \bibcloseparen%
              \setunit*{\addspace}%
              \clearfield{extradate}\clearfield{extratitleyear}%
              \printdateextra}}}% \usebibmacro{year+endyear}
        {\iffieldundef{year}%
          {\usebibmacro{origfirst+labelyear+extrayear}}%
          {\printtext{%
              \bibopenparen%
              \clearfield{extradate}\clearfield{extratitleyear}%
              \printorigdateextra%
              % \usebibmacro{origyear+endyear}%
              \bibcloseparen%
              \setunit*{\addspace}%
              \usebibmacro{standard+labelyear+extrayear}}}}%
        \usebibmacro{clear+datefield}{orig}%
        \usebibmacro{clear+datefield}{}}}}}%

\newbibmacro*{pubstate}{%
  \iffieldequalstr{pubstate}{reprint}%
  {\iftoggle{cms@switchdates}%
    {\iffieldundef{year}% Fix for consistency???
      {}%
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printdate}}}% Need \addperiod & \nopunct ??
    {\iffieldundef{origyear}%
      {}%
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printorigdate}}}}% Need \addperiod & \nopunct ??
  {}}% 17th ed.

\newbibmacro*{choosepubstring}{%
  \ifthenelse{\ifentrytype{video}\OR%
    \ifentrytype{music}}%
  {\bibstring{origreleaseyear}}%
  {\bibstring{origpubyearalt}}}%

\newbibmacro*{bibreprint}{%
  \iffieldequalstr{pubstate}{reprint}%
  {\ifentrytype{video}%
    {}%
    {\iffieldundef{origyear}%
      {\bibstring{reprint}\reprintpunct}% 16th ed. \newcunit
      {\iftoggle{cms@switchdates}%
        {\bibstring{reprint}\reprintpunct}% 16th ed. \newcunit
        {}}}}%
  {\iffieldundef{pubstate}%
    {}%
    {\iffieldbibstring{pubstate}%
      {\biblstring{\thefield{pubstate}}\reprintpunct}% \newcunit
      {\printfield[prenote]{pubstate}\reprintpunct}}}}% \newcunit

\newbibmacro*{volume+pages}{% Volume fix (modified)
  \ifboolexpr{%
    test {\iffieldundef{maintitle}}%
    or
    togl {cms@vol}%
  }%
  {\global\togglefalse{cms@vol}%
    \ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\printfield{pages}%
      \newunit%
      \printfield{volumes}}%
    {\iffieldundef{part}%
      {\iffieldundef{pages}%
        {\printfield{volume}}% Still print this w/o part or pages???
        {\ifthenelse{\iffieldnums{pages}%
            \AND\iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
          {\printfield[shortvol]{volume}%
            \postvolpunct%
            \printfield{pages}}%
          {\printfield{volume}%
            \addcomma\addspace%
            \printfield{pages}}}}%
      {\printfield{volume}%
        \printfield{part}%
        \newcunit%
        \printfield{pages}}}}%
  {\ifboolexpr{%
      togl {cms@hidevolumes}%
      and
      (
      not test {\iffieldundef{volume}}%
      or
      not test {\iffieldundef{part}}%
      )
    }%
    {\printfield{pages}}%
    {\printfield{pages}%
      \newunit%
      \printfield{volumes}}}}%

\newbibmacro*{bibprexref}{% For back references
  \iflistundef{pageref}{}{\savelist{pageref}{\cbx@incollpgref}}}%

\newbibmacro*{bibpostxref}{% Volume fix
  \iffieldundef{chapter}%
  {\iffieldundef{pages}%
    {\iffieldundef{volume}%
      {\iffieldundef{part}%
        {}%
        {\newcunit\printfield{part}}}%
      {\ifboolexpr{%
          test {\ifcsdef{cbx@incollvol}}%
          and
          test {\iffieldequalcs{volume}{cbx@incollvol}}%
        }%
        {\iffieldundef{part}%
          {}%
          {\ifboolexpr{%
              test {\ifcsdef{cbx@incollpart}}%
              and
              test {\iffieldequalcs{part}{cbx@incollpart}}%
            }%
            {}%
            {\newcunit\printfield{part}}}}%
        {\iffieldundef{part}%
          {\newcunit\printfield{volume}}%
          {\newcunit\printfield{volume}\printfield{part}}}}}%
    {\iffieldundef{volume}%
      {\iffieldundef{part}%
        {\newcunit\printfield{pages}}%
        {\newcunit\printfield{part}\newcunit\printfield{pages}}}%
      {\ifboolexpr{%
          test {\ifcsdef{cbx@incollvol}}%
          and
          test {\iffieldequalcs{volume}{cbx@incollvol}}%
        }%
        {\iffieldundef{part}%
          {\newcunit\printfield{pages}}%
          {\ifboolexpr{%
              test {\ifcsdef{cbx@incollpart}}%
              and
              test {\iffieldequalcs{part}{cbx@incollpart}}%
            }%
            {\newcunit\printfield{pages}}%
            {\newcunit\printfield{part}\newcunit\printfield{pages}}}}%
        {\iffieldundef{part}%
          {\ifthenelse{\iffieldnums{pages}%
              \AND\iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
            {\newcunit\printfield[shortvol]{volume}%
              \postvolpunct%
              \printfield{pages}}%
            {\newcunit\printfield{volume}%
              \addcomma\addspace%
              \printfield{pages}}}%
          {\newcunit\printfield{volume}%
            \printfield{part}%
            \newcunit%
            \printfield{pages}}}}}}%
  {\newcunit\printfield{chapter}}%
  \iftoggle{cms@xrefurl}%
  {\newunit%
    \usebibmacro{bib+doi+url}}%
  {}%
  \ifcsdef{cbx@incollpgref}% Here we print and clear the child's
  {\restorelist{pageref}{\cbx@incollpgref}% backrefs
    \newunit%
    \usebibmacro{pageref}%
    \global\let\cbx@incollpgref\undefined}%
  {}}%

\newbibmacro*{volume+or+volumes}{% Volume fix (modified)
  \iffieldundef{maintitle}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\printfield{volumes}}%
    {\printfield{volume}%
      \printfield{part}}}%
  {\ifboolexpr{%
      togl {cms@hidevolumes}%
      and
      (
      not test {\iffieldundef{volume}}%
      or
      not test {\iffieldundef{part}}%
      )
    }%
    {}%
    {\printfield{volumes}}}}

\def\cms@ofwrap#1{#1}

\newbibmacro*{mtitle+mstitle+vol+part+title+stitle}{%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}% Test ???
    {\iffieldundef{title}%
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}% Volume-less treatment?
      \printtext{%
        \printfield{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}%
    {\printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring[\cms@ofwrap]{ofseries}%
      \iftoggle{smartof}{}{\setunit{\addspace}}%
      \printtext{%
        \printfield[title:hook:alt]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}}%

\newbibmacro*{btitle+bstitle}{% InIn fix from N&B
  \iffieldundef{booktitle}%
  {}%
  {\ifthenelse{\ifentrytype{audio}\OR\ifentrytype{music}\OR%
      \ifentrytype{video}}%
    {}%
    {\usebibmacro{cms-in:}}%
    \printtext{%
      \printfield{booktitle}%
      \setunit{\subtitlepunct}%
      \printfield[booksubtitle]{booksubtitle}}%
    \setunit{\ctitleaddonpunct}%
    \printfield{booktitleaddon}%
    \setunit*{\addcomma\addspace}}}%

\newbibmacro*{mtitle+mstitle+vol+part+btitle+bstitle}{%
  \usebibmacro{btitle+bstitle}%
  \iffieldundef{maintitle}%
  {}%
  {\ifthenelse{\(\iffieldundef{volume}\AND\iffieldundef{part}\)\OR%
    \(\iffieldundef{booktitle}\AND\NOT\ifentrytype{bookinbook}\)}%
    {\usebibmacro{cms-in:}% Volume-less treatment?
      \printtext{%
        \printfield{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}%
      \toggletrue{cms@vol}}%
    {\printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}%
      \bibstring[\cms@ofwrap]{ofseries}%
      \iftoggle{smartof}{}{\setunit{\addspace}}%
      \printtext{%
        \printfield[title:hook:alt]{maintitle}%
        \setunit{\subtitlepunct}%
        \printfield[mainsubtitle]{mainsubtitle}}%
      \setunit{\ctitleaddonpunct}%
      \printfield{maintitleaddon}}}}%

\newbibmacro*{cjournal+ser+vol+num}[1]{% Moved to bbx
  \usebibmacro{journal+sub}{in}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \setunit*{\addspace}%
  \iffieldundef{series}%
  {}%
  {\newcunit
    \printfield[jourser]{series}%
    \newcunit}%\setunit*{\addspace}?
  \ifthenelse{\iffieldundef{#1year}\AND\iffieldundef{#1month}\AND%
    \iffieldundef{issue}\AND\iffieldundef{#1yeardivision}}%
  {\iffieldundef{volume}%
    {\newcunit%
      \printfield[journum]{number}%
      \clearfield{number}%
      \printunit{\addcomma\addspace}}%
    {\printfield[jourvol]{volume}%
      \setunit{\addcomma\addspace}}}%
  {\printfield[jourvol]{volume}%
    \newcunit%
    \printfield[journum]{number}%
    \clearfield{number}%
    \setunit{\addcomma\addspace}}}% eid moved for 17th ed.
  % \printfield{eid}%
  % \newunit}%

\newbibmacro*{journal+issue+year+pages}[1]{%
  \ifboolexpr{%
    not togl {cms@numbermonth}%
    or
    test {\ifcsstring{blx@dateformat@date}{year}}%
    }%
    {\clearfield{#1month}}%
    {}%
  \usebibmacro{cjournal+ser+vol+num}{#1}%
  \setunit{\addspace}%
  \ifthenelse{\iffieldundef{issue}\AND\iffieldundef{#1month}%
    \AND\iffieldundef{number}\AND\iffieldundef{#1year}\AND%
    \iffieldundef{#1yeardivision}}% Test year for related entries??
  {\ifthenelse{\iffieldundef{bookpagination}\AND%
      \iffieldundef{eid}\AND\NOT\iffieldundef{volume}}%
    {\setunit{\postvolpunct}}%
    {\setunit{\journalpagespunct}}}% This may not be universally correct.
  {\printtext[parens]{%  Perhaps if it's wrong use magazine subtype?
      \iffieldundef{issue}%
      {\usebibmacro{date}%
        \printfield{number}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}%
    \setunit{\journalpagespunct}}%
  \usebibmacro{eid+or+pages}}%

\newbibmacro*{periodical+issue+year+pages}[1]{%
  \ifboolexpr{%
    not togl {cms@numbermonth}%
    or
    test {\ifcsstring{blx@dateformat@date}{year}}%
  }%
  {\clearfield{#1month}}%
  {}%
  \usebibmacro{cperiodical+ser+vol+num}{#1}%
  \setunit{\addspace}%
  \ifthenelse{\iffieldundef{issue}\AND\iffieldundef{#1month}%
    \AND\iffieldundef{number}\AND\iffieldundef{#1year}\AND%
    \iffieldundef{#1yeardivision}}% See prev. macro
  {\ifthenelse{\iffieldundef{bookpagination}\AND%
      \iffieldundef{eid}\AND\NOT\iffieldundef{volume}}%
    {\setunit{\postvolpunct}}%
    {\setunit{\journalpagespunct}}}%
  {\printtext[parens]{%
      \iffieldundef{issue}%
      {\usebibmacro{date}%
        \printfield{number}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}%
    \setunit{\journalpagespunct}}%
  \usebibmacro{eid+or+pages}}%

\newbibmacro*{eid+or+pages}{%
  \iffieldundef{eid}%
  {\printfield{pages}}%
  {\printfield{eid}}}

\newbibmacro*{bycompiler}{%
  \ifnameundef{namec}%
    {}%
    {\bibstring{bycompiler}\addspace
     \printnames[bycompiler]{namec}}}

\renewbibmacro*{byeditor}{%
  \ifnameundef{editor}%
    {}%
    {\usebibmacro{bytypestrg}{editor}{editor}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \usebibmacro{editorpunct}}%
  \usebibmacro{byeditorx}}%

\renewbibmacro*{byeditorx}{%
  \ifnameundef{editora}%
    {}%
    {\usebibmacro{bytypestrg}{editora}{editor}%
     \setunit{\addspace}%
     \printnames[byeditora]{editora}%
     \usebibmacro{editorpunct}}%
  \ifnameundef{editorb}%
    {}%
    {\usebibmacro{bytypestrg}{editorb}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorb]{editorb}%
     \usebibmacro{editorpunct}}%
  \ifnameundef{editorc}%
    {}%
    {\usebibmacro{bytypestrg}{editorc}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorc]{editorc}%
     \usebibmacro{editorpunct}}}

\renewbibmacro*{byeditor+others}{%
  \ifthenelse{\NOT\ifnameundef{editor}\AND
    \(\iffieldundef{editortype}\OR
    \iffieldequalstr{editortype}{editor}\)}%
    {\def\@tempa{byeditor}%
     \ifnamesequal{editor}{translator}%
       {\edef\@tempa{\@tempa tr}%
        \clearname{translator}}%
       {}%
       \ifnamesequal{editor}{namec}%
       {\edef\@tempa{\@tempa cp}%
         \clearname{namec}}%
       {}%
     \ifnamesequal{editor}{commentator}%
       {\edef\@tempa{\@tempa co}%
        \clearname{commentator}}%
       {\ifnamesequal{editor}{annotator}%
          {\edef\@tempa{\@tempa an}%
           \clearname{annotator}}%
          {}}%
     \ifnamesequal{editor}{introduction}%
       {\edef\@tempa{\@tempa in}%
        \clearname{introduction}}%
       {\ifnamesequal{editor}{foreword}%
          {\edef\@tempa{\@tempa fo}%
           \clearname{foreword}}%
          {\ifnamesequal{editor}{afterword}%
             {\edef\@tempa{\@tempa af}%
              \clearname{afterword}}%
             {}}}%
     \bibstring{\@tempa}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \clearname{editor}%
     \usebibmacro{editorpunct}%
     \usebibmacro{byeditorx}}%
   {\usebibmacro{byeditor}}%
  \usebibmacro{bytranslator+others}}%

\renewbibmacro*{bytranslator+others}{%
  \ifnameundef{translator}%
    {}%
    {\def\@tempa{bytranslator}%
      \ifnamesequal{translator}{namec}%
      {\edef\@tempa{\@tempa cp}%
        \clearname{namec}}%
      {}%
     \ifnamesequal{translator}{commentator}%
       {\edef\@tempa{\@tempa co}%
        \clearname{commentator}}%
       {\ifnamesequal{translator}{annotator}%
          {\edef\@tempa{\@tempa an}%
           \clearname{annotator}}%
          {}}%
     \ifnamesequal{translator}{introduction}%
       {\edef\@tempa{\@tempa in}%
        \clearname{introduction}}%
       {\ifnamesequal{translator}{foreword}%
          {\edef\@tempa{\@tempa fo}%
           \clearname{foreword}}%
          {\ifnamesequal{translator}{afterword}%
             {\edef\@tempa{\@tempa af}%
              \clearname{afterword}}%
             {}}}%
     \bibstring{\@tempa}\space
     \printnames[bytranslator]{translator}%
     \clearname{translator}%
     \usebibmacro{editorpunct}}%
  \usebibmacro{bycompiler+others}}%

\newbibmacro*{bycompiler+others}{%
  \ifnameundef{namec}%
    {}%
    {\def\@tempa{bycompiler}%
     \ifnamesequal{namec}{commentator}%
       {\edef\@tempa{\@tempa co}%
        \clearname{commentator}}%
       {\ifnamesequal{namec}{annotator}%
          {\edef\@tempa{\@tempa an}%
           \clearname{annotator}}%
          {}}%
     \ifnamesequal{namec}{introduction}%
       {\edef\@tempa{\@tempa in}%
        \clearname{introduction}}%
       {\ifnamesequal{namec}{foreword}%
          {\edef\@tempa{\@tempa fo}%
           \clearname{foreword}}%
          {\ifnamesequal{namec}{afterword}%
             {\edef\@tempa{\@tempa af}%
              \clearname{afterword}}%
             {}}}%
     \bibstring{\@tempa}\space
     \printnames[bycompiler]{namec}%
     \clearname{namec}%
     \usebibmacro{editorpunct}}%
  \usebibmacro{byothers}}%

\newbibmacro*{byothers}{% Changed for 0.9
  \usebibmacro{cbytranslator}%
  \usebibmacro{editorpunct}%
  \usebibmacro{bycompiler}%
  \usebibmacro{editorpunct}%
%  \usebibmacro{byredactor}%
%  \usebibmacro{editorpunct}%
  \usebibmacro{withcommentator}%
  \usebibmacro{editorpunct}%
  \usebibmacro{withannotator}%
  \usebibmacro{editorpunct}%
  \usebibmacro{withintroduction}%
  \usebibmacro{editorpunct}%
  \usebibmacro{withforeword}%
  \usebibmacro{editorpunct}%
  \usebibmacro{withafterword}}%

%%%% Related functionality from standard.bbx %%%%

\providecommand*{\mkrelatedstringtext}[1]{{{\mainlang #1}}}

\newcounter{bbx:relatedcount}
\newcounter{bbx:relatedtotal}

\newbibmacro*{related:init}{%
  \csundef{bbx:relatedloop}}

\newbibmacro*{begrelated}{\ifcsdef{bbx@lasthash}%
  {\let\cms@related@hash\bbx@lasthash}{}}%
\newbibmacro*{endrelated}{\ifcsdef{cms@related@hash}%
  {\global\let\bbx@lasthash\cms@related@hash%
    \let\cms@related@hash\undefined}{}\global\undef\cbx@lasthash}%
\newbibmacro*{begrelatedloop}{}
\newbibmacro*{endrelatedloop}{}

\renewcommand*{\begrelateddelim}{%
  \ifthenelse{\ifentrytype{jurisdiction}\OR\ifentrytype{legal}\OR%
    \ifentrytype{legislation}}%
  {\newcunitpunct}%
  {\newunitpunct}}%

\newcommand*{\begrelateddelimmaintitle}{\newunitpunct\par\nobreak}%
\newcommand*{\begrelateddelimmaintitlenc}{\newunitpunct\par\nobreak}%

% The idea here is to support standard multicite presentation via the
% 'short' relatedtype mechanism.

\newcommand*{\relateddelimshort}{%
  \iffieldequals{fullhash}{\cbx@lasthash}%
  {\ifbool{cms:atcite}{\addsemicolon\addspace}{\addcomma\addspace}}%
  {\addsemicolon\addspace}}%

\def\ifrelatedloop{%
  \ifboolexpr{ test {\xifinlistcs{\strfield{entrykey}}{bbx:relatedloop}}%
    or test {\xifinlistcs{\strfield{clonesourcekey}}{bbx:relatedloop}} }}%

\newbibmacro*{related}{%
  \ifboolexpr{ test {\iffieldundef{related}} or test {\ifrelatedloop} }%
    {}%
    {\ifcsundef{begrelateddelim\strfield{relatedtype}}%
       {\printunit{\begrelateddelim}}%
       {\printunit{\csuse{begrelateddelim\strfield{relatedtype}}}}%
     \usebibmacro{begrelated}%
     \def\bbx@tempa{}%
     \setcounter{bbx:relatedtotal}{0}%
     \def\do##1{%
       \entrydata{##1}{%
         \ifrelatedloop%
           {}%
           {\stepcounter{bbx:relatedtotal}%
            \gappto{\bbx@tempa}{##1,}}}}%
     \docsvfield{related}%
     \restorefield{related}{\bbx@tempa}%
     \ifnumgreater{\value{bbx:relatedtotal}}{0}%
       {\listcsxadd{bbx:relatedloop}{\strfield{entrykey}}%
        \iffieldundef{clonesourcekey}%
          {}%
          {\listcsxadd{bbx:relatedloop}{\strfield{clonesourcekey}}}%
        \setcounter{bbx:relatedcount}{0}%
        \def\do{%
          \stepcounter{bbx:relatedcount}%
          \ifnumgreater{\value{bbx:relatedcount}}{1}%
            {\ifcsundef{relateddelim\strfield{relatedtype}}%
              {\printunit{\relateddelim}}%
              {\expandafter\expandafter\expandafter\expandafter\expandafter
                \expandafter\expandafter\printunit
                \expandafter\expandafter\expandafter\expandafter\expandafter
                \expandafter\expandafter{%
                  \csuse{relateddelim\strfield{relatedtype}}}}}%
            {}}%
        \ifbibmacroundef{related:\strfield{relatedtype}}%
          {\appto{\do}{\usebibmacro{related:default}}}%
          {\appto{\do}{\usebibmacro*{related:\strfield{relatedtype}}}}%
        \iffieldformatundef{related:\strfield{relatedtype}}%
          {\def\bbx@tempa{related}}%
          {\def\bbx@tempa{related:\strfield{relatedtype}}}%
        \iffieldformatundef{relatedstring:\strfield{relatedtype}}%
          {\def\bbx@tempb{relatedstring:default}}%
          {\def\bbx@tempb{relatedstring:\strfield{relatedtype}}}%
        \printtext[\bbx@tempa]{%
          \usebibmacro{begrelatedloop}%
          \iffieldundef{relatedstring}%
            {\ifboolexpr{%
               test {\ifnumgreater{\value{bbx:relatedtotal}}{1}}%
               and
               test {\ifbibxstring{\thefield{relatedtype}s}}%
             }%
               {\printtext[\bbx@tempb]{%
                  \bibstring[\mkrelatedstringtext]{\thefield{relatedtype}s}}}%
               {\iffieldbibstring{relatedtype}%
                  {\printtext[\bbx@tempb]{%
                     \bibstring[\mkrelatedstringtext]{\thefield{relatedtype}}}}%
                  {}}}%
            {\iffieldbibstring{relatedstring}%
               {\printtext[\bbx@tempb]{%
                  \bibstring[\mkrelatedstringtext]{\thefield{relatedstring}}}}%
               {\printfield[\bbx@tempb]{relatedstring}}}%
          \docsvfield{related}%
          \usebibmacro{endrelatedloop}}}%
       {}%
     \usebibmacro{endrelated}}}%

\NewBibliographyString{%
   afterwordto,%
   broadcast,%
   by,%
   bychoreographer,%
   bycompileraf,%
   bycompileran,%
   bycompileranaf,%
   bycompileranfo,%
   bycompileranin,%
   bycompilerco,%
   bycompilercoaf,%
   bycompilercofo,%
   bycompilercoin,%
   bycompilerfo,%
   bycompilerin,%
   byconductor,%
   bydirector,%
   byeditoralt,%
   byeditorcp,%
   byeditorcpaf,%
   byeditorcpan,%
   byeditorcpanaf,%
   byeditorcpanfo,%
   byeditorcpanin,%
   byeditorcpco,%
   byeditorcpcoaf,%
   byeditorcpcofo,%
   byeditorcpcoin,%
   byeditorcpfo,%
   byeditorcpin,%
   byeditortrcp,%
   byeditortrcpaf,%
   byeditortrcpan,%
   byeditortrcpanaf,%
   byeditortrcpanfo,%
   byeditortrcpanin,%
   byeditortrcpco,%
   byeditortrcpcoaf,%
   byeditortrcpcofo,%
   byeditortrcpcoin,%
   byeditortrcpfo,%
   byeditortrcpin,%
   bynone,%
   byproducer,%
   bytranslatorcp,%
   bytranslatorcpaf,%
   bytranslatorcpan,%
   bytranslatorcpanaf,%
   bytranslatorcpanfo,%
   bytranslatorcpanin,%
   bytranslatorcpco,%
   bytranslatorcpcoaf,%
   bytranslatorcpcofo,%
   bytranslatorcpcoin,%
   bytranslatorcpfo,%
   bytranslatorcpin,%
   canadasection,%
   canadasections,%
   cbyannotator,%
   cbyauthor,%
   cbychoreographer,%
   cbycollaborator,%
   cbycommentator,%
   cbycompiler,%
   cbycompileraf,%
   cbycompileran,%
   cbycompileranaf,%
   cbycompileranfo,%
   cbycompileranin,%
   cbycompilerco,%
   cbycompilercoaf,%
   cbycompilercofo,%
   cbycompilercoin,%
   cbycompilerfo,%
   cbycompilerin,%
   cbyconductor,%
   cbycontinuator,%
   cbydirector,%
   cbyeditor,%
   cbyeditoraf,%
   cbyeditoralt,%
   cbyeditoran,%
   cbyeditoranaf,%
   cbyeditoranfo,%
   cbyeditoranin,%
   cbyeditorco,%
   cbyeditorcoaf,%
   cbyeditorcofo,%
   cbyeditorcoin,%
   cbyeditorcp,%
   cbyeditorcpaf,%
   cbyeditorcpan,%
   cbyeditorcpanaf,%
   cbyeditorcpanfo,%
   cbyeditorcpanin,%
   cbyeditorcpco,%
   cbyeditorcpcoaf,%
   cbyeditorcpcofo,%
   cbyeditorcpcoin,%
   cbyeditorcpfo,%
   cbyeditorcpin,%
   cbyeditorfo,%
   cbyeditorin,%
   cbyeditortr,%
   cbyeditortraf,%
   cbyeditortran,%
   cbyeditortranaf,%
   cbyeditortranfo,%
   cbyeditortranin,%
   cbyeditortrco,%
   cbyeditortrcoaf,%
   cbyeditortrcofo,%
   cbyeditortrcoin,%
   cbyeditortrcp,%
   cbyeditortrcpaf,%
   cbyeditortrcpan,%
   cbyeditortrcpanaf,%
   cbyeditortrcpanfo,%
   cbyeditortrcpanin,%
   cbyeditortrcpco,%
   cbyeditortrcpcoaf,%
   cbyeditortrcpcofo,%
   cbyeditortrcpcoin,%
   cbyeditortrcpfo,%
   cbyeditortrcpin,%
   cbyeditortrfo,%
   cbyeditortrin,%
   cbyfounder,%
   cbynone,%
   cbyorganizer,%
   cbyproducer,%
   cbyredactor,%
   cbytranslator,%
   cbytranslatoraf,%
   cbytranslatoran,%
   cbytranslatoranaf,%
   cbytranslatoranfo,%
   cbytranslatoranin,%
   cbytranslatorco,%
   cbytranslatorcoaf,%
   cbytranslatorcofo,%
   cbytranslatorcoin,%
   cbytranslatorcp,%
   cbytranslatorcpaf,%
   cbytranslatorcpan,%
   cbytranslatorcpanaf,%
   cbytranslatorcpanfo,%
   cbytranslatorcpanin,%
   cbytranslatorcpco,%
   cbytranslatorcpcoaf,%
   cbytranslatorcpcofo,%
   cbytranslatorcpcoin,%
   cbytranslatorcpfo,%
   cbytranslatorcpin,%
   cbytranslatorfo,%
   cbytranslatorin,%
   century,%
   cfromamerican,%
   cfrombrazilian,%
   cfrombulgarian,%
   cfromcatalan,%
   cfromcroatian,%
   cfromczech,%
   cfromdanish,%
   cfromdutch,%
   cfromenglish,%
   cfromestonian,%
   cfromfinnish,%
   cfromfrench,%
   cfromgalician,%
   cfromgerman,%
   cfromgreek,%
   cfromitalian,%
   cfromjapanese,%
   cfromlatin,%
   cfromnorwegian,%
   cfrompolish,%
   cfromportuguese,%
   cfromrussian,%
   cfromslovak,%
   cfromslovene,%
   cfromspanish,%
   cfromswedish,%
   cfromukrainian,%
   choreographer,%
   choreographers,%
   commenton,%
   conductor,%
   conductors,%
   decade,%
   director,%
   directors,%
   discrecorded,%
   edamerican,%
   edbrazilian,%
   edbulgarian,%
   edcatalan,%
   edcroatian,%
   edczech,%
   eddanish,%
   eddutch,%
   edenglish,%
   edestonian,%
   edfinnish,%
   edfrench,%
   edgalician,%
   edgerman,%
   edgreek,%
   editalian,%
   editorcompiler,%
   editorcompilers,%
   editortranscompiler,%
   editortranscompilers,%
   editortranslator,%
   editortranslators,%
   edjapanese,%
   edlatin,%
   ednorwegian,%
   edpolish,%
   edportuguese,%
   edrussian,%
   edslovak,%
   edslovene,%
   edspanish,%
   edswedish,%
   edukrainian,%
   forewordto,%
   hereinafter,%
   inlang,%
   introductionto,%
   none,%
   nones,%
   note,%
   numbers,%
   of,%
   on,%
   origedition,%
   origpub,%
   origpublin,%
   origpubyear,%
   origpubyearalt,%
   origreleaseyear,%
   origshownyear,%
   partvolume,%
   patentfiled,%
   patentissued,%
   preface,%
   printed,%
   producer,%
   producers,%
   pseudonym,%
   review,%
   revisededition,%
   selfpublished,%
   songrecorded,%
   subsection,%
   subsections,%
   subverbis,%
   subverbo,%
   supranote,%
   tome,%
   track,%
   transcompiler,%
   transcompilers%
 }%

\endinput
