% $Id: chicago-notes.cbx,v 0.9.7.114 2014/08/21 16:25:50 dfussner Exp $
% This is a biblatex citation style file, adapted from Lehman's
% authortitle-cverb.cbx.  It is heavily modified, with the intention
% of providing footnote citations and a bibliography formatted
% according to the specifications of the Chicago Manual of Style.

\ProvidesFile{chicago-notes.cbx}[2014/08/21 v 2.9a biblatex citation style]

%%%% Biblatex initialization + Chicago options + Toggles %%%%

\providecommand*{\mkibid}[1]{#1}

\providetoggle{cms@oneyear}% Needed for author-date
\providetoggle{cms@reprint}% ditto
\providetoggle{cms@switchdates}% ditto

\providetoggle{cms@jrcomma}% For comma before Jr./Sr.

\providetoggle{cms@url}% These are for the field-exclusion options
\providetoggle{cms@doi}
\providetoggle{cms@doionly}
\providetoggle{cms@eprint}
\providetoggle{cms@isbn}
\providetoggle{cms@numbermonth}
\providetoggle{cms@bookpages}
\providetoggle{cms@hidevolumes}% Modify volume fix
\providetoggle{cms@bookseries}
\providetoggle{cms@notefield}
\providetoggle{cms@addendum}
\providetoggle{cms@comprange}
\providetoggle{cms@modpostnote}

\providetoggle{cms@headlessnote}
\providetoggle{cms@origcite}
\providetoggle{cms@fullnote}
\providetoggle{cms@shortnote}
\providetoggle{cms@allshort}
\providetoggle{cms@noibid}
\providetoggle{cms@usecompiler}
\providetoggle{cms@shorthandibid}
\providetoggle{cms@printshhand}
\providetoggle{cms@fullshhand}
\providetoggle{cms@inheritshhand}
\providetoggle{cms@origpublished}
\providetoggle{cms@loccit}
\providetoggle{cms@annotation}
\providetoggle{cms@postposit}
\providetoggle{cms@vol}
\providetoggle{cms@postvol}
\providetoggle{cms@usedvol}
\providetoggle{cms@citecrossref}
\providetoggle{cms@bibcrossref}
\providetoggle{cms@bookcitexref}
\providetoggle{cms@bookbibxref}
\providetoggle{cms@xrefvol}
\providetoggle{cms@xrefpart}
\providetoggle{cms@omitxrefdate}

\AtEveryCitekey{%
  \iffieldundef{userc}%
  {}%
  {\nocite{\thefield{userc}}}%
  \global\togglefalse{cms@loccit}%
  \iffieldequalstr{pubstate}{reprint}%
  {\toggletrue{cms@reprint}}%
  {\togglefalse{cms@reprint}}%
  \ifboolexpr{%
    test {\iffieldundef{origyear}}%
    or
    test {\iffieldundef{year}}%
    or
    not test {\iffieldint{year}}%
    or
    not test {\iffieldint{origyear}}%
    or
    togl {cms@switchdates}%
  }%
  {}%
  {\ifboolexpr{% Needed for open-ended ranges
      test {\iffieldundef{endyear}}%
      or
      not test {\iffieldnum{endyear}}%
    }%
    {\ifthenelse{\thefield{origyear}>\thefield{year}}%
      {\toggletrue{cms@switchdates}}%
      {}}%
    {\ifthenelse{\thefield{origyear}>\thefield{endyear}}%
      {\toggletrue{cms@switchdates}}%
      {}}}}%

\DeclareBibliographyOption{annotation}[true]{%
  \global\toggletrue{cms@annotation}}

\DeclareBibliographyOption{noibid}[true]{%
  \global\toggletrue{cms@noibid}}

\DeclareBibliographyOption{short}[true]{%
  \global\toggletrue{cms@allshort}}

\DeclareBibliographyOption{shorthandibid}[true]{%
  \global\toggletrue{cms@shorthandibid}}

\DeclareBibliographyOption{shorthandfull}[true]{%
  \settoggle{cms@fullshhand}{#1}}

\DeclareBibliographyOption{inheritshorthand}[true]{%
  \settoggle{cms@inheritshhand}{#1}
  \iftoggle{cms@inheritshhand}%
  {\DeclareDataInheritance{*}{*}{%
  \inherit{shorthand}{shorthand}
  \inherit{shorthandintro}{shorthandintro}
  }}%
  {}}

\DeclareBibliographyOption{compresspages}[true]{%
  \ifcsdef{cms@opt@crange@#1}%
  {\csuse{cms@opt@crange@#1}}%
  {\blx@err@invopt{compresspages=#1}{}}}%
\def\cms@opt@crange@true{%
  \global\toggletrue{cms@comprange}%
  \setcounter{mincomprange}{100}%
  \setcounter{mincompwidth}{10}%
}%
\def\cms@opt@crange@false{}%

\DeclareBibliographyOption{postnotepunct}[true]{%
  \ifcsdef{cms@opt@ppunct@#1}%
  {\csuse{cms@opt@ppunct@#1}}%
  {\blx@err@invopt{postnotepunct=#1}{}}}%
\def\cms@opt@ppunct@true{%
  \global\toggletrue{cms@modpostnote}}%
\def\cms@opt@ppunct@false{}%

\DeclareBibliographyOption{usecompiler}[true]{%
  \settoggle{cms@usecompiler}{#1}}

\DeclareEntryOption{usecompiler}[true]{%
  \settoggle{cms@usecompiler}{#1}}

\DeclareBibliographyOption{juniorcomma}[true]{%
  \settoggle{cms@jrcomma}{#1}}

\DeclareEntryOption{juniorcomma}[true]{%
  \settoggle{cms@jrcomma}{#1}}

\DeclareBibliographyOption{delayvolume}[true]{%
  \settoggle{cms@postvol}{#1}}

\DeclareEntryOption{delayvolume}[true]{%
  \settoggle{cms@postvol}{#1}}

\DeclareBibliographyOption{longcrossref}[false]{%
  \ifcsdef{cms@opt@lxref@#1}%
  {\csuse{cms@opt@lxref@#1}}
  {\blx@err@invopt{longcrossref=#1}{}}}
\def\cms@opt@lxref@none{%
  \togglefalse{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}%
  \togglefalse{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}
\def\cms@opt@lxref@true{%
  \toggletrue{cms@citecrossref}%
  \toggletrue{cms@bibcrossref}}%
\def\cms@opt@lxref@false{%
  \togglefalse{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}}%
\def\cms@opt@lxref@notes{%
  \toggletrue{cms@citecrossref}%
  \togglefalse{cms@bibcrossref}}%
\def\cms@opt@lxref@bib{%
  \togglefalse{cms@citecrossref}%
  \toggletrue{cms@bibcrossref}}%

\DeclareEntryOption{longcrossref}[false]{%
  \ifcsdef{cms@opt@doi@#1}%
  {\csuse{cms@opt@doi@#1}}
  {\blx@err@invopt{doi=#1}{}}}

\DeclareBibliographyOption{booklongxref}[true]{%
  \ifcsdef{cms@opt@bklxref@#1}%
  {\csuse{cms@opt@bklxref@#1}}
  {\blx@err@invopt{booklongxref=#1}{}}}%
\def\cms@opt@bklxref@true{%
  \toggletrue{cms@bookcitexref}%
  \toggletrue{cms@bookbibxref}}%
\def\cms@opt@bklxref@false{%
  \togglefalse{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}%
\def\cms@opt@bklxref@notes{%
  \toggletrue{cms@bookcitexref}%
  \togglefalse{cms@bookbibxref}}%
\def\cms@opt@bklxref@bib{%
  \togglefalse{cms@bookcitexref}%
  \toggletrue{cms@bookbibxref}}%

\DeclareEntryOption{booklongxref}[true]{%
  \ifcsdef{cms@opt@bklxref@#1}%
  {\csuse{cms@opt@bklxref@#1}}
  {\blx@err@invopt{booklongxref=#1}{}}}%

\DeclareBibliographyOption{omitxrefdate}[true]{%
  \settoggle{cms@omitxrefdate}{#1}}

\DeclareEntryOption{omitxrefdate}[true]{%
  \settoggle{cms@omitxrefdate}{#1}}

% The field-exclusion options %

\DeclareBibliographyOption{isbn}[true]{%
  \settoggle{cms@isbn}{#1}}
\DeclareBibliographyOption{url}[true]{%
  \settoggle{cms@url}{#1}}
\DeclareBibliographyOption{doi}[true]{%
  \ifcsdef{cms@opt@doi@#1}%
  {\csuse{cms@opt@doi@#1}}
  {\blx@err@invopt{doi=#1}{}}}
\def\cms@opt@doi@true{%
  \toggletrue{cms@doi}}
\def\cms@opt@doi@false{%
  \togglefalse{cms@doi}}
\def\cms@opt@doi@only{%
  \toggletrue{cms@doionly}}
\DeclareBibliographyOption{eprint}[true]{%
  \settoggle{cms@eprint}{#1}}
\DeclareBibliographyOption{numbermonth}[true]{%
  \settoggle{cms@numbermonth}{#1}}
\DeclareBibliographyOption{bookpages}[true]{%
  \settoggle{cms@bookpages}{#1}}
\DeclareBibliographyOption{includeall}[true]{%
  \settoggle{cms@isbn}{#1}%
  \settoggle{cms@url}{#1}%
  \settoggle{cms@doi}{#1}%
  \settoggle{cms@eprint}{#1}%
  \settoggle{cms@numbermonth}{#1}%
  \settoggle{cms@bookpages}{#1}}
\DeclareBibliographyOption{hidevolumes}[true]{%
  \settoggle{cms@hidevolumes}{#1}}

\DeclareBibliographyOption{addendum}[true]{%
  \settoggle{cms@addendum}{#1}}
\DeclareBibliographyOption{bookseries}[true]{%
  \settoggle{cms@bookseries}{#1}}
\DeclareBibliographyOption{notefield}[true]{%
  \settoggle{cms@notefield}{#1}}
\DeclareBibliographyOption{completenotes}[true]{%
  \settoggle{cms@addendum}{#1}%
  \settoggle{cms@bookseries}{#1}%
  \settoggle{cms@notefield}{#1}}%

\DeclareEntryOption{isbn}[true]{%
  \settoggle{cms@isbn}{#1}}
\DeclareEntryOption{url}[true]{%
  \settoggle{cms@url}{#1}}
\DeclareEntryOption{doi}[true]{%
  \ifcsdef{cms@opt@doi@#1}%
  {\iftoggle{cms@doi}%
    {\togglefalse{cms@doi}%
      \iftoggle{cms@doionly}%
      {\togglefalse{cms@doionly}}% !!
      {}}%
    {\toggletrue{cms@doi}}% !!
    \csuse{cms@opt@doi@#1}}
  {\blx@err@invopt{doi=#1}{}}}
\DeclareEntryOption{eprint}[true]{%
  \settoggle{cms@eprint}{#1}}
\DeclareEntryOption{numbermonth}[true]{%
  \settoggle{cms@numbermonth}{#1}}
\DeclareEntryOption{bookpages}[true]{%
  \settoggle{cms@bookpages}{#1}}
\DeclareEntryOption{hidevolumes}[true]{%
  \settoggle{cms@hidevolumes}{#1}}

\DeclareEntryOption{addendum}[true]{%
  \settoggle{cms@addendum}{#1}}
\DeclareEntryOption{bookseries}[true]{%
  \settoggle{cms@bookseries}{#1}}
\DeclareEntryOption{notefield}[true]{%
  \settoggle{cms@notefield}{#1}}

\ExecuteBibliographyOptions{includeall,completenotes,hidevolumes,booklongxref}

% For author-date compatibility %

\DeclareEntryOption{switchdates}[true]{%
  \settoggle{cms@switchdates}{#1}}

\DeclareEntryOption{cmsdate}{}%

\DeclareBibliographyOption{cmsdate}{}%

\DeclareBibliographyOption{strict}[true]{%
  \let\splitfootnoterule\footnoterule
  \renewcommand\footnoterule{}%
  \advance\skip\footins 4\p@\@plus2\p@\relax
  \gdef\split@prev{0}
  \let\pagefootnoterule\footnoterule
  % \def\splitfootnoterule{\kern-3\p@ \hrule \kern2.6\p@}
  \def\footnoterule{\relax
    \ifnum\split@prev=\z@
    \pagefootnoterule
    \else
    \splitfootnoterule
    \fi
    \xdef\split@prev{\the\insertpenalties}%
  }}


\protected\def\blx@newcunit{%
  \global\let\blx@unitpunct\newcunitpunct
  \global\toggletrue{blx@unit}}%

\appto\blx@blxinit{%
  \let\newcunit\blx@newcunit}

\newcommand*{\newcunitpunct}{\addcomma\space}

\def\mkbibcurdinal#1{%
  \@tempcnta0#1 \the\@tempcnta}%

\@ifpackagelater{biblatex}{2010/08/28}
{}
{\PackageError{biblatex}
  {Outdated 'biblatex' package}
  {The Chicago style requires biblatex v0.9 or later.\MessageBreak
    You are using: '\csuse{ver@biblatex.sty}'.\MessageBreak
    This is a fatal error. I'm aborting now.}%
  \endinput}

% American-specific punctuation change for 16th edition %

\DefineBibliographyExtras{american}{%
  \DeclarePunctuationPairs{comma}{*!?}}

%%%% Initialize and define bibstrings %%%%

\DefineBibliographyStrings{english}{%
  citedas = {hereafter cited as},}

%%%% This one needed for 16th edition. Others in cms-*.lbx %%%%

%%%% Cite macros for use by the citation commands %%%%

\newbibmacro*{cite:init}{%
  \global\let\cbx@lastkey\undefined}

\newbibmacro*{cite:save}{%
  \savefield{entrykey}{\cbx@lastkey}}

\newbibmacro*{cite}{%
  \ifciteseen%
    {\ifboolexpr{
        test {\iffieldundef{shorthand}}%
        or
        (
        togl {blx@skipbiblist}%
        and
        togl {cms@inheritshhand}%
        and
        not test {\iffieldundef{crossref}}%
        )
      }
       {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
          {\usebibmacro{cite:ibid}}%
          {\global\toggletrue{cms@shortnote}%
            \global\togglefalse{cms@fullnote}%
            \usebibmacro{cite:short}%
           \usebibmacro{cite:save}}}%
       {\iftoggle{cms@shorthandibid}%
         {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
           {\usebibmacro{cite:ibid}}%
           {\usebibmacro{cite:shorthand}%
             \usebibmacro{cite:save}}}%
         {\usebibmacro{cite:shorthand}%
           \usebibmacro{cite:save}}}}%
    {\iftoggle{cms@allshort}%
      {\global\toggletrue{cms@shortnote}%
        \global\togglefalse{cms@fullnote}%
        \global\toggletrue{cms@printshhand}%
        \usebibmacro{cite:short}%
        \usebibmacro{cite:save}}%
      {\global\toggletrue{cms@fullnote}%
        \global\togglefalse{cms@shortnote}%
        \usebibmacro{cite:full}%
        \usebibmacro{cite:save}}}}%

\newbibmacro*{cite:full}{%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}\frenchspacing}
      {cite:\thefield{entrytype}}}}%

\newbibmacro*{cite:short}{%
  \ifthenelse{\ifnameundef{labelname}\OR%
    \ifentrytype{inreference}\OR%
    \ifentrytype{reference}\OR%
    \ifentrytype{mvreference}}%
  {\iffieldequalstr{entrysubtype}{magazine}% Simplify .bib creation
    {\ifuseauthor%
      {\printfield[journaltitle]{journaltitle}\isdot\newcunit}%
      {}}%
    {\ifentrytype{manual}%
      {\printlist{organization}\isdot\newcunit}%
      {}}}%
  {\iffieldequalstr{authortype}{anon}%
    {\bibleftbracket\printnames{labelname}%
      \bibrightbracket\classicpunct}%
    {\iffieldequalstr{authortype}{anon?}%
      {\bibleftbracket\printnames{labelname}?%
        \bibrightbracket\classicpunct}%
      {\usebibmacro{choose+labelname}%\printnames{labelname}%
        \isdot\classicpunct}}}%
  \ifboolexpr{%
    togl {cms@allshort}%
    or
    test {\ifbibliography}%
  }%
  {\printtext[bibhyperref]{%
    \printfield[citetitle]{labeltitle}}}%
  {\printtext[cmshyperlink]{%
    \printfield[citetitle]{labeltitle}}}}%:\thefield{entrytype}?

\newbibmacro*{cite:shorthand}{%
  \iftoggle{cms@allshort}%
  {\printtext[bibhyperref]{%
      \printfield{shorthand}}}
  {\printtext[cmshyperlink]{%
      \printfield{shorthand}}}}

\newbibmacro*{cms:shorthandintro}{% For changing the citedas phrase
  \iffieldundef{shorthand}%
  {}%
  {\iffieldundef{shorthandintro}%
    {%\addspace%\setunit{\addspace}% Fix for after postnote field
      \printtext[parens]{%
        \bibstring{citedas}\space%
        \printfield{shorthand}}}%
    {%\addspace%\setunit{\addspace}% Ditto
      \printfield{shorthandintro}}}}

\newbibmacro*{cite:ibid}{%
  \ifboolexpr{%
    togl {cms@noibid}%
    or
    test {\ifbibliography}% Needed for inheritshorthand option
  }%
  {\global\toggletrue{cms@shortnote}%
    \global\togglefalse{cms@fullnote}%
    \usebibmacro{cite:short}%
    \usebibmacro{cite:save}}%
  {\iftoggle{cms@allshort}%
    {\printtext[bibhyperref]{%
        \bibstring[\mkibid]{ibidem}}}%
    {\printtext[cmshyperlink]{%
        \bibstring[\mkibid]{ibidem}}}%
    \ifboolexpr{%
      test {\ifloccit}%
      or
      (
      test {\ifciteibid}%
      and
      test {\iffieldequalcs{postnote}{cms@pnsaved}}%
      and
      not test {\ifdefvoid{\blx@loccittracker}}% Package option=false
      )
    }%
    {\global\toggletrue{cms@loccit}}%
    {}}}

\newbibmacro*{cite:journal}{%
  \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
  {\iffieldundef{prenote}%
    {\bibsentence\usebibmacro{cite:ibid}}%
    {\usebibmacro{cite:ibid}}}%
  {\iffieldundef{journaltitle}%
    {\usebibmacro{cite:short}}%
    {\iffieldequalstr{authortype}{anon}%
      {\bibleftbracket\printnames{labelname}%
        \bibrightbracket\newcunit}%
      {\iffieldequalstr{authortype}{anon?}%
        {\bibleftbracket\printnames{labelname}?%
          \bibrightbracket\newcunit}%
        {\printnames{labelname}%
          \isdot\newcunit}}%
      \iftoggle{cms@allshort}%
      {\printtext[bibhyperref]{%
          \printfield[journaltitle]{journaltitle}}}%
      {\printtext[bibhyperlink]{%
          \printfield[journaltitle]{journaltitle}}}%
      \iffieldundef{volume}%
      {\iffieldundef{number}%
        {\iffieldundef{issue}
          {\newcunit%
            \usebibmacro{number+or+month}}%
          {\newcunit%
            \printfield{issue}%
            \setunit{\addspace}%
            \usebibmacro{cmsyear}}}%
        {\newcunit%
          \printfield[journum]{number}}}%
      {\toggletrue{cms@fullnote}%
        \togglefalse{cms@shortnote}%
        \setunit{\addspace}%
        \printfield[jourvol]{volume}%
        \ifthenelse{\iffieldundef{pagination}\AND%
          \iffieldundef{bookpagination}}%
        {\setunit{\postvolpunct}}%
        {\setunit{\addcolon\addspace}}}}}}

%% Macros from verbose.cbx %%

\newbibmacro*{textcite}{%
  \ifnameundef{labelname}
    {\printfield[citetitle]{labeltitle}}
    {\printnames{labelname}}}

\newbibmacro*{textcite:init}{%
  \citetrackerfalse%
  \pagetrackerfalse%
  \iffirstcitekey
    {\global\undef\cbx@lasthash}
    {}}

\newbibmacro*{textcite:count}{%
  \stepcounter{textcitetotal}%
  \ifnumgreater{\value{uniquelist}}{\value{maxnames}}
    {\ifnumgreater{\value{uniquelist}}{\value{textcitemaxnames}}
       {\setcounter{textcitemaxnames}{\value{uniquelist}}}
       {}}
    {\ifnumless{\value{labelname}}{\value{maxnames}}
       {\ifnumgreater{\value{labelname}}{\value{textcitemaxnames}}
          {\setcounter{textcitemaxnames}{\value{labelname}}}
          {}}
       {\ifnumgreater{\value{maxnames}}{\value{textcitemaxnames}}
          {\setcounter{textcitemaxnames}{\value{maxnames}}}
          {}}}}

%%%% Citation Commands, internal and external %%%%

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\cmsnoopcite}%
{}{}{}{}%

\DeclareCiteCommand{\bibxrefcite}
  {\usebibmacro{backref+check}}% So cites in biblio don't turn up
  {\usebibmacro{cms-in:}%        in backref list
    \ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND\NOT%
      \(\ifentrytype{collection}\OR\ifentrytype{proceedings}\OR%
      \ifentrytype{mvcollection}\OR\ifentrytype{mvproceedings}\)}%
    {\clearname{author}%
      \clearname{shortauthor}%
      \clearname{labelname}}%
    {}%
    \toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \ifboolexpr{
      togl {cms@inheritshhand}%
      and
      not test {\iffieldundef{shorthand}}%
    }
    {\usebibmacro{cite}}%
    {\usebibmacro{cite:short}}}% Would {cite} be better?
  {}
  {\usebibmacro{crossref:volume+postnote}}% Volume fix

\DeclareCiteCommand{\bookbibxrefcite}
  {\usebibmacro{backref+check}}% So cites in biblio don't turn up
  {\iffieldequals{fullhash}{\bbx@lasthash}% in backref list
    {\ifthenelse{\ifentrytype{collection}\OR%
        \ifentrytype{proceedings}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}}%
      {\clearname{editor}%
        \clearname{shorteditor}%
        \clearname{labelname}}%
      {\clearname{author}%
        \clearname{shortauthor}%
        \clearname{labelname}}}%
    {}%
    \toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \usebibmacro{bibxref-in:}%
    \ifboolexpr{%
      togl {cms@inheritshhand}%
      and
      not test {\iffieldundef{shorthand}}%
    }%
    {\usebibmacro{cite}}%
    {\usebibmacro{cite:short}}}%
  {}%
  {\usebibmacro{crossref:volume+postnote}}% Volume fix

\DeclareCiteCommand*{\cite}
  {\usebibmacro{cite:init}%
    \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \blx@ibidreset
    \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\smartcite}
  [\iffootnote{}{\mkbibfootnote}]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareMultiCiteCommand{\smartcites}[\iffootnote{}{\mkbibfootnote}]%
{\smartcite}{\multicitedelim}

\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
    \toggletrue{cms@fullnote}%
    \togglefalse{cms@shortnote}%
   \usebibmacro{cite:full}%
   \usebibmacro{cite:save}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}%\bibsentence
  {\usebibmacro{citeindex}%
    \toggletrue{cms@fullnote}%
    \togglefalse{cms@shortnote}%
   \usebibmacro{cite:full}
   \usebibmacro{cite:save}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\origfullcite}
  {\usebibmacro{backref+check}%
    \ifhyperref%
    {\hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}%
    {}%
    \nopunct\unspace}% Put \nopunct and \unspace here for 0.8e.
  {\usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \usebibmacro{clearorigin}\clearfield{userf}\clearfield{shorthand}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \frenchspacing}%
    {cite:\thefield{entrytype}}%
    \iflistundef{pageref}{}{\newunit\usebibmacro{pageref}}}%
  {\multicitedelim}%
  {\finentry}% Helps with annotated bibliographies (?)

\DeclareCiteCommand{\origpublcite}% Similar to above, w/o title.
  {\usebibmacro{backref+check}%
    \ifhyperref%
    {\hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}%
    {}%
    \nopunct\unspace}% Put \nopunct and \unspace here for 0.8e.
  {\usedriver
    {\DeclareNameAlias{sortname}{default}\clearfield{postnote}%
      \usebibmacro{clearpublin}\clearfield{shorthand}%
      \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
      \toggletrue{cms@origpublished}\frenchspacing}%
    {cite:\thefield{entrytype}}%
    \iflistundef{pageref}{}{\newunit\usebibmacro{pageref}}}%
  {\multicitedelim}%
  {\finentry}

\DeclareCiteCommand{\headlessfullcite}
  {\usebibmacro{hlprenote}}%
  {\printtext[bibhypertarget]{%
      \usedriver
      {\DeclareNameAlias{sortname}{default}\clearname{author}%
        \toggletrue{cms@fullnote}\toggletrue{cms@headlessnote}%
        \usebibmacro{cite:save}}%
      {cite:\thefield{entrytype}}}}%
  {\multicitedelim}%
  {}%\usebibmacro{finentry}}

\DeclareCiteCommand{\headlesscite}
  {\usebibmacro{hlcprenote}}
  {\usebibmacro{citeindex}%
    \toggletrue{cms@headlessnote}%
    \clearname{author}%
    \clearname{shortauthor}%
    \clearname{labelname}%
    \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\headlessparencite}[\mkbibparens]
  {\usebibmacro{hlcprenote}}
  {\usebibmacro{citeindex}%
    \toggletrue{cms@headlessnote}%
    \clearname{author}%
    \clearname{shortauthor}%
    \clearname{labelname}%
    \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\headlessparenshortcite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \toggletrue{cms@headlessnote}%
    \toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \clearname{author}%
    \clearname{shortauthor}%
    \clearname{labelname}%
    \usebibmacro{cite:short}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\surnamecite}
  {\usebibmacro{prenote}}%\usebibmacro{hlcprenote}}
  {\usebibmacro{citeindex}%
    \ifboolexpr{%
      test {\ifciteseen}%
      or
      togl {cms@allshort}%
    }%
    {\usebibmacro{cite:short}}
    {\toggletrue{cms@headlessnote}%
      \usebibmacro{choose+surname}%
      \usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareMultiCiteCommand{\surnamecites}{surnamecite}{\multicitedelim}

\DeclareCiteCommand{\shortcite}
  {\usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \usebibmacro{citeindex}%
    \usebibmacro{cite:short}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\shorthandcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \iftoggle{cms@shorthandibid}%
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
      {\usebibmacro{cite:ibid}}%
      {\usebibmacro{cite:shorthand}%
        \usebibmacro{cite:save}}}%
    {\usebibmacro{cite:shorthand}%
      \usebibmacro{cite:save}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citejournal}% Name?
  {\usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \clearfield{pages}%
    \usebibmacro{citeindex}%
    \usebibmacro{cite:journal}}
  {\multicitedelim}
  {\iftoggle{cms@loccit}%
    {}%
    {\usebibmacro{fullpostnote}}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\toggletrue{cms@shortnote}%
    \togglefalse{cms@fullnote}%
    \ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\citetitles}{citetitle}{\multicitedelim}

\DeclareMultiCiteCommand{\headlesscites}{headlesscite}{\multicitedelim}

\DeclareMultiCiteCommand{\headlessparencites}[\mkbibparens]%
{headlessparencite}{\multicitedelim}

\DeclareMultiCiteCommand{\headlessparenshortcites}[\mkbibparens]%
{headlessparenshortcite}{\multicitedelim}

%% Textcite commands adapted from verbose.cbx %%

\DeclareCiteCommand{\cbx@textcite}
  {\usebibmacro{textcite:init}}
  {\iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\iffirstcitekey
        {}
        {\textcitedelim}%
      \stepcounter{textcitecount}%
      \usebibmacro{textcite}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite\cms@textcite@i]
  {\usebibmacro{textcite:init}%
   \gdef\cbx@savedkeys{}%
   \DeferNextCitekeyHook}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@footcite@args{%
        (\thefield{multiprenote})(\thefield{multipostnote})}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\usebibmacro{textcite:count}%
      \savefield{namehash}{\cbx@lasthash}}%
   \ifnumequal{\value{citecount}}{\value{citetotal}}
     {\protected@xappto\cbx@textcite@args{{\cbx@savedkeys}}%
      \protected@xappto\cbx@footcite@args{%
        [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}%
      \iflastcitekey
        {\iffootnote
          {\protected@xappto\cbx@textcite@args{\nopunct}%
            \protected@xappto\cbx@footcite@args{\thefield{postpunct}}}%
          {\protected@xappto\cbx@textcite@args{\thefield{postpunct}}% Switch
            \protected@xappto\cbx@footcite@args{\nopunct}}}% these two?
        {}}
     {}}
  {}
  {}

\newrobustcmd{\cbx@textcite@init}[3]{%
  \setcounter{textcitetotal}{0}%
  \setcounter{textcitecount}{0}%
  \setcounter{textcitemaxnames}{0}%
  \def\cbx@textcite@args{#1}\def\cbx@footcite@args{#2}#3%
  \cbx@textcite@args\empty\cbx@footcite@args\empty}

\DeclareMultiCiteCommand{\cbx@textcites}{\cbx@textcite}{}
\DeclareMultiCiteCommand{\textcites}
  [\cbx@textcites@init\cbx@textcites\cms@textcites@i]{\textcite}{}

\let\cbx@textcites@init\cbx@textcite@init
\pretocmd{\cbx@textcites@init}{%
  \UseNextMultiCiteHook%
  \AtNextMultiCite{%
    \renewbibmacro{multiprenote}{}%
    \renewbibmacro{multipostnote}{}}}{}{}

\renewcommand*{\textcitedelim}{%
  \iffinalcitedelim
  {\ifnumgreater{\value{textcitetotal}}{2}
    {\addcomma}%
    {}%
    \addspace\bibstring{and}}
  {\addcomma}%
  \space}

\newrobustcmd{\cms@textcite@i}{%
  \iffootnote{\foottextcite}{\footcite}}

\newrobustcmd{\cms@textcites@i}{%
  \iffootnote{\foottextcites}{\footcites}}

\newcommand{\foottextcite}{\addspace\headlessparenshortcite}

\newcommand{\foottextcites}{\addspace\headlessparenshortcites}

%%%% Drivers for the Long Note Format %%%%

\DeclareBibliographyDriver{cite:article}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{cmag+news+author}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{cmag+news+title}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{mag+news+date}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}
  {\usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{cmag+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{note}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cjournal+issue+year+pages}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:artwork}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:audio}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}
  {}
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\usebibmacro{cms-in:}%
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \newcunit
  \printfield{type}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isan}%
    \newcunit\newblock
    \printfield{ismn}}%
  {}%
  \newcunit\newblock%
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{cite:xref+date}%
  \newcunit
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit\newblock
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \iftoggle{cms@bookpages}%
  {}%
  {\clearfield{pages}}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \printlist[][-\value{listtotal}]{lista}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:bookinbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{cite:xref+date}%
  \newcunit\newblock
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }
  {\usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:booklet}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{howpubl+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:collection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}
  \usebibmacro{cite:xref+date}%
  \newcunit
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit\newblock
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbytranslator+others}%
  \newcunit\newblock
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work. Only with Vol?
    {\ifbibliography%
      {\setunit{\bibsentence}}{\addspace\bibsentence}}%
    {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:customc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \newcunit\newblock
  \printfield{nameaddon}%
  \setunit*{\addspace}%
  \usebibmacro{italtitle+stitle}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:image}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit%\setunit{\addcomma\addspace}%
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:inbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }
  {\usebibmacro{chapincoll}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}%
  \usebibmacro{cite:xref+finentry}}%
{\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:incollection}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock%
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit
      \iffieldundef{edition}%
      {}%
      {\usebibmacro{edition}}%
      \newcunit
      \usebibmacro{bybookauthor}%
      \usebibmacro{cbyeditor+others}%
      \newcunit
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \newcunit\newblock
      \usebibmacro{cpubl+loc+year}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:inproceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cpart+editor+translator}%
  \setunit{\addcomma\addspace}%
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit\newblock
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \setunit{\addspace}\newblock%
      \printtext[parens]{%
        \usebibmacro{org+publ+loc+year}}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}%
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{inreffullpostnote}%
  \newcunit\newblock%setunit{\addspace}% 16th ed
  \ifnameundef{author}%
  {}%
  {\printtext{% 16th ed
      \bibstring{by}%
      \addspace%
      \printnames{author}}}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:letter}{%
  \usebibmacro{bibindex}%
  \savefield{fullhash}{\bbx@lasthash}%
  \printtext[title]{%
    \printfield[noformat]{title}}%
  \newcunit\newblock%
  \printfield{titleaddon}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{letter+date}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newcunit\newblock%
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@citecrossref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@citecrossref}%
    }
    {\usebibmacro{chapincoll}%
      \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
      \newcunit
      \iffieldundef{edition}%
      {}%
      {\usebibmacro{edition}}%
      \newcunit
      \usebibmacro{bybookauthor}%
      \usebibmacro{cbyeditor+others}%
      \newcunit
      \usebibmacro{volume+or+volumes}%
      \newcunit\newblock
      \usebibmacro{cser+num}%
      \newcunit\newblock
      \usebibmacro{cnotefield}%
      \newcunit\newblock
      \usebibmacro{cpubletter+loc+year}%
      \usebibmacro{caddendum}%
      \usebibmacro{volfullpostnote}%
      \newcunit\newblock
      \iftoggle{cms@isbn}%
      {\printfield{isbn}}%
      {}%
      \newcunit\newblock
      \usebibmacro{cite+doi+url}%
      \setunit{\addspace}%
      \usebibmacro{cms:shorthandintro}%
      \newcunit\newblock
      \usebibmacro{pageref}%
      \usebibmacro{finentry}%
      \usebibmacro{cite:xref+finentry}}%
    {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
      \usebibmacro{xrefprenote}% Volume fix
      \usebibmacro{xrefchapincoll}%
      \bibxrefcite{\thefield{xref}}%
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}{\setunit{\addspace\bibsentence}}{\newcunit}% 16th ed.
    \usebibmacro{xrefprenote}% Volume fix
    \usebibmacro{xrefchapincoll}%
    \bibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:manual}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author+org}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock%
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \usebibmacro{edition}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{org+publ+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:misc}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \iffieldundef{entrysubtype}%
  {\usebibmacro{citaltitle+stitle}}%
  {\printfield{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}%
    \newcunit\newblock%
    \printfield{titleaddon}%
    \setunit{\addspace}%
    \usebibmacro{language+transtitle}%
    \newcunit\newblock
    \usebibmacro{unpubl+letter+date}}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cbyeditor+others}%
  \newcunit\newblock
  \printfield{howpublished}%
  \newcunit\newblock
  \printfield{type}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \printfield{note}%
  \newcunit\newblock
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \iffieldundef{entrysubtype}%
  {\newcunit\newblock
    \usebibmacro{date}}%
  {}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:music}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit\newblock
  \usebibmacro{cpart+editor+translator}%
  \newcunit\newblock
  \usebibmacro{music+eventdate}%
  \newcunit\newblock
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}
  {}
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\usebibmacro{cms-in:}%
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{music+origdate}%\printtext[eventdate]{\printeventdate}%
  \newcunit\newblock
  \printlist{publisher}%
  \newcunit\newblock
  \printfield{series}%
  \setunit{\addspace}%
  \printfield{number}%
  \newcunit\newblock
  \usebibmacro{date}%
  \newcunit
  \usebibmacro{institution+organization}%
  \newcunit\newblock
  \printlist{location}%
  \newcunit\newblock
  \printfield{type}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \usebibmacro{pubstate}% 16th ed.
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{iswc}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{cite:mvbook}{cite:book}

\DeclareBibliographyAlias{cite:mvcollection}{cite:collection}

\DeclareBibliographyAlias{cite:mvproceedings}{cite:proceedings}

\DeclareBibliographyAlias{cite:mvreference}{cite:reference}

\DeclareBibliographyDriver{cite:online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \printlist{organization}% Rearranged for 16th ed.
  \setunit{\addcomma\addspace}%
  \usebibmacro{cnotefield}%
  \setunit{\addcomma\addspace}
  \usebibmacro{date}%
  \usebibmacro{fullpostnote}%
  \setunit{\addcomma\addspace}%
  \iffieldundef{urlyear}%
  {}%
  {\printurldate}% Date fix
  \newcunit\newblock
  \iftoggle{cms@doionly}%
  {\iffieldundef{doi}%
    {}%
    {\printfield{doi}%
      \clearfield{url}}}%
  {\printfield{doi}}%
  \newcunit\newblock
  \usebibmacro{eprint}%
  \newcunit\newblock
  \printfield{url}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:patent}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author+holder}% +holder?
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}\newblock%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}%
  \printtext[parens]{%
  \printfield{type}%
  \setunit*{\addspace}%
  \printfield{number}%
  \iflistundef{location}
    {}
    {\setunit*{\addspace}%
     \printtext[parens]{%
       \printlist[][-\value{listtotal}]{location}}}%
  \newcunit\newblock
  \printfield{version}%
  \newcunit
  \iffieldundef{origyear}%
  {\iffieldundef{year}%
    {}%
    {\bibstring{patentfiled}\setunit{\addspace}% Changed to filed
      \printdate}}%
  {\bibstring{patentfiled}\setunit{\addspace}%
    \usebibmacro{cmsorigdate}%
    \setunit{\addcomma\addspace\bibstring{and}%
      \addspace\bibstring{patentissued}\addspace}%
  \usebibmacro{date}}%
  \usebibmacro{caddendum}}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:periodical}{%
  \iffieldequalstr{entrysubtype}{magazine}%
  {\usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{periodical+date+issue}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}%
  {\usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{issuetitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cperiodical+issue+year+pages}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:proceedings}{%
  \usebibmacro{bibindex}%
  \usebibmacro{editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock%
  \usebibmacro{citaltitle+stitle}%
  \setunit{\addspace}
  \usebibmacro{cite:xref+date}%
  \newcunit
  \ifboolexpr{
    test {\iffieldundef{crossref}}%
    or
    not test {\ifentryseen{\thefield{crossref}}}%
    or
    togl {cms@bookcitexref}%
  }
  {\ifboolexpr{
      test {\iffieldundef{xref}}%
      or
      not test {\ifentryseen{\thefield{xref}}}%
      or
      togl {cms@bookcitexref}%
    }
  {\usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit\newblock
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
  \usebibmacro{org+publ+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}%
  \usebibmacro{book:xref+finentry}}%
    {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
      \usebibmacro{xrefprenote}% Volume fix
      \bookbibxrefcite{\thefield{xref}}% Removed \addspace from each.
      \usebibmacro{xrefpostnote}%
      \usebibmacro{finentry}}}%
  {\ifpunctmark{.}% This seems to work.
      {\ifbibliography%
        {\setunit{\bibsentence}}{\addspace\bibsentence}}%
      {\ifbibliography{\unspace}{\addcomma\addspace}}% ?!?
    \usebibmacro{xrefprenote}% Volume fix
    \bookbibxrefcite{\thefield{crossref}}%
    \usebibmacro{xrefpostnote}%
    \usebibmacro{finentry}}}

\DeclareBibliographyDriver{cite:reference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{citaltitle+stitle}%
  \newcunit\newblock
  \ifthenelse{\iffieldundef{maintitle}\AND\iffieldundef{booktitle}}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmtitle+mstitle+vol+part+btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit%
  \printfield{type}%
  \newcunit
  \printfield{series}%
  \setunit{\addnbspace}%
  \printfield{number}%
  \newcunit%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{% 
  \usebibmacro{inst+loc+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isrn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:review}{%
  \usebibmacro{bibindex}%
  \iffieldequalstr{entrysubtype}{magazine}
  {\usebibmacro{cmag+news+author}}%
  {\usebibmacro{author/editor}}%
  \newcunit\newblock
  \printeventdate% 16th ed.
  \setunit{\addspace}%
  \printfield{nameaddon}% 16th ed.
  \newcunit\newblock
  \printfield{title}%
  \setunit{\addcolon\addspace}%
  \printfield[noformat]{subtitle}%
  \newcunit\newblock
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%\newblock%
  \usebibmacro{cpart+editor+translator}%
  \newcunit%
  \usebibmacro{issuetitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addcomma\addspace}%
  \printfield{note}%
  \setunit{\addcomma\addspace}%
  \iffieldequalstr{entrysubtype}{magazine}
  {\usebibmacro{mag+news+date}}%
  {\usebibmacro{cjournal+issue+year+pages}}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{issn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:suppbook}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{inforaft}%
  \setunit{\addspace}\newblock
  \usebibmacro{citaltitle+stitle}%
  \newcunit
  \iffieldundef{maintitle}%
  {\iffieldundef{edition}%
    {}%
    {\usebibmacro{edition}}}%
  {}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \newcunit\newblock
  \usebibmacro{cmtitle+mstitle+vol+part+title+stitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{cbyeditor+others}%
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \clearfield{pages}% ?? For 16th ed.
  \usebibmacro{caddendum}%
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isbn}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyAlias{cite:suppcollection}{cite:suppbook}

\DeclareBibliographyAlias{cite:suppperiodical}{cite:review}

\DeclareBibliographyDriver{cite:thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{cnotefield}%
  \setunit{\addspace}%
  \printtext[parens]{%
  \usebibmacro{type+inst+year}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:unpublished}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \setunit{\addcomma\addspace}\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{byauthor}%
  \newcunit\newblock%
  \usebibmacro{cbyeditor+others}%
  \setunit{\addspace}\newblock%
  \printtext[parens]{%
    \printfield{howpublished}%
    \newcunit\newblock
    \usebibmacro{cnotefield}%
    \newcunit\newblock
    \printlist{location}%
    \newcunit\newblock
    \usebibmacro{date}}%
  \usebibmacro{caddendum}%
  \usebibmacro{fullpostnote}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{cite:video}{%
  \usebibmacro{bibindex}%
  \usebibmacro{author/editor}%
  \setunit{\addspace}%
  \printfield{nameaddon}%
  \newcunit\newblock
  \usebibmacro{ctitle+stitle}%
  \setunit{\addspace}\newblock%
  \usebibmacro{language+transtitle}%
  \newcunit
  \usebibmacro{byauthor}%
  \newcunit
  \usebibmacro{cpart+editor+translator}%
  \newcunit
  \usebibmacro{chapinscore}%
  \usebibmacro{btitle+bstitle}%
  \newcunit
  \iffieldundef{edition}%
  {}%
  {\usebibmacro{edition}}%
  \newcunit
  \usebibmacro{bybookauthor}%
  \usebibmacro{cbyeditor+others}%
  \iffieldundef{maintitle}
  {}
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\usebibmacro{cms-in:}%
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}}
  \newcunit
  \usebibmacro{volume+or+volumes}%
  \newcunit\newblock
  \usebibmacro{cser+num}%
  \newcunit\newblock
  \usebibmacro{music+eventdate}%
  \newcunit\newblock
  \usebibmacro{cnotefield}%
  \newcunit\newblock
  \usebibmacro{cpubl+loc+year}%
  \newcunit\newblock
  \printfield{type}% Order of this and next?
  \usebibmacro{volfullpostnote}%
  \newcunit\newblock
  \usebibmacro{caddendum}%
  \newcunit\newblock
  \iftoggle{cms@isbn}%
  {\printfield{isan}}%
  {}%
  \newcunit\newblock
  \usebibmacro{cite+doi+url}%
  \setunit{\addspace}%
  \usebibmacro{cms:shorthandintro}%
  \newcunit\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}

%%%% List Formats %%%%

\DeclareListFormat{language}{%
  \ifthenelse{\value{listcount}=1}%
  {\bibleftbracket\bibstring{inlang}%\addspace - for inflected langs.
    \ifbibstring{#1}
    {\bibstring{#1}}
    {\ifbibstring{lang#1}
      {\bibstring{lang#1}}
      {#1}}%
    \ifthenelse{\value{listtotal}=1}%
    {\bibrightbracket}%
    {}}%
  {\ifthenelse{\value{listcount}=\value{listtotal}}%
    {\multilangdelim%
      \ifbibstring{#1}
      {\bibstring{#1}}
      {\ifbibstring{lang#1}
        {\bibstring{lang#1}}
        {#1}}%
      \bibrightbracket}%
    {\multilangdelim%
      \ifbibstring{#1}
      {\bibstring{#1}}
      {\ifbibstring{lang#1}
        {\bibstring{lang#1}}
        {#1}}}}%
  \usebibmacro{langlist:andothers}}

\DeclareListFormat{publisher}{%
  \ifthenelse{\value{listtotal}<2}%
  {#1\isdot}%
  {\ifthenelse{\value{listcount}=1}%
    {#1}%
    {\multipubsdelim #1\isdot}}}

\DeclareListFormat{periodplace}{\mkbibparens{#1}}

\DeclareListFormat{lista}{% 
  \ifthenelse{\value{listtotal}<2}
  {s\adddot v\adddot\addspace\mkbibquote{#1\isdot}}%
  {\ifthenelse{\value{listcount}=1}%
    {s\adddot vv\adddot\addspace \mkbibquote{#1\isdot}\addcomma}%
    {\ifthenelse{\value{listcount}<\value{listtotal}}%
      {\addspace\mkbibquote{#1\isdot}\addcomma}%
      {\addspace\mkbibquote{#1\isdot}}}}}

%%%% Field Formats -- Title, Citetitle, Lostitle %%%%

\DeclareFieldFormat{title}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{citetitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat{lostitle}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{title}{%
  \iffieldundef{title}%
  {}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{citetitle}{%
  \iffieldundef{title}%
  {#1\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat
[article,inbook,incollection,inproceedings,online,thesis,unpublished]
{lostitle}{%
  \iffieldundef{title}%
  {#1\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[artwork,image]{title}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[artwork,image]{citetitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[artwork,image]{lostitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {#1\isdot}}

\DeclareFieldFormat[letter,patent]{title}{#1\isdot}

\DeclareFieldFormat[letter,patent]{citetitle}{#1\isdot}

\DeclareFieldFormat[letter,patent]{lostitle}{#1\isdot}

\DeclareFieldFormat{prenote}{\ifcapital{\MakeCapital{#1}}{#1}}

\iftoggle{cms@comprange}% Audrey Boruvka's code from StackExchange
{\patchcmd{\blx@comprange@check}%
  {\blx@comprange@comp{#1}{#2}}%
  {\blx@tempcnta=#1%
    \divide\blx@tempcnta100%
    \multiply\blx@tempcnta100%
    \ifnumequal{\blx@tempcnta}{#1}%
    {\blx@range@out@value{#1\bibrangedash#2}}%
    {\blx@comprange@comp{#1}{#2}}}%
  {}{}}{}%

\DeclareFieldFormat{postnote}{% Changed for page compression option
  \iftoggle{cms@comprange}%
  {\iffieldundef{pagination}%
    {\mkcomprange{#1}}%
    {\mkcomprange[{\mkpageprefix[pagination]}]{#1}}}%
  {\iffieldundef{pagination}%
    {#1}%
    {\mkpageprefix[pagination]{#1}}}}%

\DeclareFieldFormat[inreference]{postnote}{%
  \iftoggle{cms@comprange}%
  {\iffieldundef{pagination}%
    {s\adddot v\adddot\addspace\mkbibquote{#1}}%
    {\mkcomprange[{\mkpageprefix[pagination]}]{#1}}}%
  {\iffieldundef{pagination}%
    {s\adddot v\adddot\addspace\mkbibquote{#1}}%
    {\mkpageprefix[pagination]{#1}}}}%

\DeclareFieldFormat{pages}{%
  \iftoggle{cms@comprange}%
  {\iffieldundef{bookpagination}%
    {\mkcomprange{#1}\isdot}%
    {\mkcomprange[{\mkpageprefix[bookpagination]}]{#1}}}%
  {\iffieldundef{bookpagination}%
    {#1\isdot}%
    {\mkpageprefix[bookpagination]{#1}}}}%

\DeclareFieldFormat{edlang}{%
  \ifbibstring{#1}
  {\bibstring{#1}}
  {\ifbibstring{ed#1}
    {\bibstring{ed#1}}
    {\ifcapital{\MakeCapital{#1}}{#1}}}}

\DeclareFieldFormat[suppbook,suppcollection]{title}{\mkbibemph{#1}\isdot}

\DeclareFieldFormat[suppbook,suppcollection]{citetitle}{%
  \usebibmacro{inforaft}%
  \addspace%
  \mkbibemph{#1}\isdot}

\DeclareFieldFormat[suppbook,suppcollection]{lostitle}{%
  \usebibmacro{inforaft}%
  \addspace%
  \mkbibemph{#1}\isdot}

\DeclareFieldFormat[customc]{title}{%
  \iffieldundef{nameaddon}%
  {\mkbibemph{\bibstring{see}}%
    \addspace%
    #1}%
  {#1}}

\DeclareFieldFormat[customc]{citetitle}{%
  \iffieldundef{nameaddon}%
  {\mkbibemph{\bibstring{see}}%
    \addspace%
    #1}%
  {\printfield{nameaddon}\addspace #1}}

\DeclareFieldFormat[misc]{title}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[misc]{citetitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[misc]{lostitle}{%
  \iffieldundef{entrysubtype}%
  {\mkbibemph{#1}\isdot}%
  {\ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}}

\DeclareFieldFormat[review,suppperiodical]{title}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[review,suppperiodical]{citetitle}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[review,suppperiodical]{lostitle}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

\DeclareFieldFormat[audio,music,video]{title}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[audio,music,video]{citetitle}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

\DeclareFieldFormat[audio,music,video]{lostitle}{%
  \iffieldundef{booktitle}%
  {\mkbibemph{#1}\isdot}%
  {\mkbibquote{#1\isdot}}}

%%%% Other Field Formats %%%%

\DeclareNumChars*{:}% For proper ibidem with multi-volume works.

\DeclareFieldFormat{letterday}{\mkbibcurdinal{#1}}

\DeclareFieldFormat{note}{%
  \ifcapital{\MakeCapital{#1}}{#1}}%

\DeclareFieldFormat
[audio,manual,music,patent,report,suppbook,suppcollection,thesis,video]
{type}{%
  \ifbibstring{#1}%
  {\bibstring{#1}}%
  {\ifcapital%
    {\MakeCapital{#1\isdot}}%
    {#1\isdot}}}

\DeclareFieldFormat[artwork,image]{type}{%
  \ifcapital%
  {\MakeCapital{#1}}%
  {#1}}

\DeclareFieldFormat{url}{\url{#1}}

\DeclareFieldFormat{doi}{%
  \textrm{doi}\addcolon
  \ifhyperref
    {\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}

\DeclareFieldFormat[music]{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}%
  \OR\NOT\iffieldundef{eventyear}\OR\NOT\iffieldundef{origyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}%
  \OR\NOT\iffieldundef{eventyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat{date}{% Generalize userd ???
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{urlyear}}%
  {#1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat{urldate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{urlseen}\space #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{urldate}{% 16th ed.
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}}%
  {\bibstring{urlseen}\space #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[music]{urldate}{% 16th ed.
  \ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}%
    \OR\NOT\iffieldundef{origyear}}%
  {\bibstring{urlseen}\space #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[music]{origdate}{% 16th ed.
  \iftoggle{cms@reprint}% Date fix
  {#1}%
  {\ifthenelse{\iffieldundef{userd}\OR\NOT\iffieldundef{eventyear}}%
    {\bibstring{recorded}\space #1}%
    {\printfield{userd}\addspace #1}}}

\DeclareFieldFormat[music]{eventdate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{recorded}\space #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldFormat[video]{eventdate}{% 16th ed.
  \iffieldundef{userd}%
  {\bibstring{broadcast}\space #1}%
  {\printfield{userd}\addspace #1}}

\DeclareFieldAlias{userd}{titleaddon}% 16th ed.

\DeclareFieldFormat{nameaddon}{\mkbibbrackets{#1\bibsentence}}% ?!

\DeclareFieldFormat[review]{nameaddon}{#1\bibsentence}

\DeclareFieldFormat[customc]{nameaddon}{% For cross-refs
  \ifbibstring{#1}%
  {\mkbibemph{\bibstring{#1}}}%
  {#1}}

\DeclareFieldFormat{edition}{% New in 0.8
  \ifinteger{#1}
  {\mkbibordedition{#1}~\bibstring{edition}}%
  {\ifcapital
    {\MakeCapital{#1\isdot}}%
    {#1\isdot}}}

\DeclareFieldFormat{year}{% To cope with abbreviation n.d.
  \iftoggle{cms@fullnote}%
  {#1\bibsentence}%
  {#1\isdot}}% (?)

\DeclareFieldFormat[misc]{year}{#1\isdot}

\DeclareFieldFormat[article]{year}{% To cope with abbreviation n.d.
  \iffieldequalstr{entrysubtype}{magazine}%
  {#1\isdot}
  {#1\bibsentence}}

\DeclareFieldAlias[review]{year}[article]{year}

\DeclareFieldAlias[periodical]{year}[article]{year}

\DeclareFieldAlias[suppperiodical]{year}[article]{year}

\DeclareFieldFormat{usere}{[#1]} % Better than mkbibbrackets?

\DeclareFieldFormat{titleaddon}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}%\custpunctc?

\DeclareFieldAlias{booktitleaddon}{titleaddon}

\DeclareFieldAlias{maintitleaddon}{titleaddon}

\DeclareFieldFormat{issuetitle}{\mkbibquote{#1\isdot}}

\DeclareFieldFormat{jourser}{%
  \ifinteger{#1}%
  {\mkbibordseries{#1}%
    \addnbspace%
    \bibstring{jourser}}%
  {\ifbibstring{#1}{\bibstring{#1}}{#1}}}

\DeclareFieldFormat{journum}{% Revised for 0.9.5
  \ifboolexpr{%
    test {\ifnumerals{#1}}%
    and
    not test {\ifnumeral{#1}}%
  }%
  {\bibstring{numbers}\addspace #1}%
  {\bibstring{number}\addspace #1}}

\DeclareFieldFormat{sernum}{%
  \ifnumeral{#1}%
  {\addnbspace #1}%
  {\addcomma\addspace #1}}

\DeclareFieldFormat{series}{#1\isdot}

\DeclareFieldFormat{addendum}{%
  \ifcapital{\MakeCapital{#1\isdot}}{#1\isdot}}

% This works better here than in the entrytail macro -- userf use is
% no longer a problem, though the page breaking still isn't ideal.

\DeclareFieldFormat{annotation}{\par\nobreak \vskip \bibitemsep #1}

\DeclareFieldFormat{part}{% xref revision ???
  \ifnumerals{#1}%
  {\addcomma\addspace\bibstring{partvolume}~#1}%
  {\addcomma\addspace\ifcapital{\MakeCapital{#1}}{#1}}}

\DeclareFieldFormat{xrefpart}{% xref revision ???
  \ifnumerals{#1}%
  {\bibstring{partvolume}~#1}%
  {\ifcapital{\MakeCapital{#1}}{#1}}}

%% This tries to get hyperlinks from shortened cross-ref'd notes to %%
%% long notes working properly.  Used in short and shorthand cites. %%

\DeclareFieldFormat{cmshyperlink}{%
  \iffieldundef{crossref}%
  {\iffieldundef{xref}%
    {\bibhyperlink{\thefield{entrykey}}{#1}}%
    {\ifboolexpr{((
        test {\ifentrytype{book}}%
        or
        test {\ifentrytype{bookinbook}}%
        or
        test {\ifentrytype{collection}}%
        or
        test {\ifentrytype{proceedings}}%
        )
        and
        not togl {cms@bookcitexref}%
        )
        or
        ((
        test {\ifentrytype{inbook}}%
        or
        test {\ifentrytype{letter}}%
        or
        test {\ifentrytype{incollection}}%
        or
        test {\ifentrytype{inproceedings}}%
        )
        and
        not togl {cms@citecrossref}%
        )
      }%
      {\bibhyperlink{\thefield{xref}}{#1}}%
      {\bibhyperlink{\thefield{entrykey}}{#1}}}}%
  {\ifboolexpr{((
        test {\ifentrytype{book}}%
        or
        test {\ifentrytype{bookinbook}}%
        or
        test {\ifentrytype{collection}}%
        or
        test {\ifentrytype{proceedings}}%
        )
        and
        not togl {cms@bookcitexref}%
        )
        or
        ((
        test {\ifentrytype{inbook}}%
        or
        test {\ifentrytype{letter}}%
        or
        test {\ifentrytype{incollection}}%
        or
        test {\ifentrytype{inproceedings}}%
        )
        and
        not togl {cms@citecrossref}%
        )
      }%
      {\bibhyperlink{\thefield{crossref}}{#1}}%
      {\bibhyperlink{\thefield{entrykey}}{#1}}}}

\DeclareFieldAlias[review]{volume}[article]{volume}

\DeclareFieldAlias[suppperiodical]{volume}[article]{volume}

%%%% Commands, for users and internal %%%%

\newcommand*{\cbytypeeditor}{%
  \iffieldundef{editortype}
    {\bibstring{cbytypeeditor}}
    {\bibstring{cbytype\thefield{editortype}}}}

\renewcommand*{\multicitedelim}{\addsemicolon\space}

\renewcommand*{\iffinalcitedelim}{%
  \ifnumequal{\value{textcitecount}}{\value{textcitetotal}-1}}

\newcommand{\custpunct}{%
  \iftoggle{cms@fullnote}%
  {\iffieldequalstr{type}{plain}%
    {}
    {\addcomma}}%
  {\iftoggle{cms@shortnote}
    {\iffieldundef{postnote}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}
        {\addperiod}}%
      {\addcomma}}%
    {\addperiod}}}

\newcommand{\custpunctb}{%
  \iftoggle{cms@fullnote}%
  {\iffieldequalstr{userb}{plain}%
    {}
    {\addcomma}}%
  {\iftoggle{cms@shortnote}
    {\iffieldundef{postnote}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}
        {\addperiod}}%
      {\addcomma}}%
    {\addperiod}}}

\newcommand{\classicpunct}{% 16th ed.
  \ifthenelse{\(\iffieldequalstr{entrysubtype}{classical}\AND%
    \iffieldundef{labeltitle}\)\OR
    \ifentrytype{letter}}%
  {\setunit*{\addspace}}%
  {\setunit*{\addcomma\addspace}}}

\newcommand{\reprintpunct}{%
  \iftoggle{cms@fullnote}%
  {\setunit*{\addsemicolon\addspace}}%
  {\setunit*{\addperiod\addspace}}}

\newcommand{\encypunct}{% for named entries in an encyclopedia
  \iftoggle{cms@fullnote}%
  {\ifentrytype{book}%
    {\ifthenelse{\iffieldundef{addendum}\AND\iffieldundef{doi}\AND
        \iffieldundef{isbn}\AND\iffieldundef{url}}%
      {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
        {}%
        {\addperiod}}%
      {\addcomma}}%
    {\ifnameundef{author}%
      {\ifthenelse{\iffieldundef{addendum}\AND\iffieldundef{doi}\AND
          \iffieldundef{isbn}\AND\iffieldundef{url}}%
        {\ifthenelse{\value{multicitecount} < \value{multicitetotal}}%
          {}%
          {\addperiod}}%
        {\addcomma}}%
      {}}}%
  {\ifentrytype{book}%
    {\addperiod}%
    {\ifnameundef{author}%
      {\addperiod}%
      {}}}}

\newcommand{\postvolpunct}{\addcolon}% For vol:page customization

\newcommand{\parttrans}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbytranslator}\space}%
  {\bibstring{bytranslator}\space}}

\newcommand{\partedit}{%
  \iftoggle{cms@postposit}% Kludge to make it work in French.
  {\iftoggle{cms@fullnote}%
    {\bibstring{cbyeditoralt}\addspace}%
    {\bibstring{byeditoralt}\addspace}}%
  {\iftoggle{cms@fullnote}%
    {\bibstring{cbyeditor}\addspace}%
    {\bibstring{byeditor}\addspace}}}

\newcommand{\partcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbycompiler}\space}%
  {\bibstring{bycompiler}\space}}

\newcommand{\parteditandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditorcp}\space}%
  {\bibstring{byeditorcp}\space}}

\newcommand{\parttransandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbytranslatorcp}\space}%
  {\bibstring{bytranslatorcp}\space}}

\newcommand{\partedittransandcomp}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditortrcp}\space}%
  {\bibstring{byeditortrcp}\space}}

\newcommand{\parteditandtrans}{%
  \iftoggle{cms@fullnote}%
  {\bibstring{cbyeditortr}\space}%
  {\bibstring{byeditortr}\space}}

\newcommand{\reprint}{%
  \iftoggle{cms@fullnote}%
  {\bibsstring{reprint}}%
  {\bibstring{reprint}}}

\newcommand*{\multipubsdelim}{\addnbspace/\addspace}

\newcommand*{\multilocsdelim}{%
  \ifthenelse{\value{listcount}<\value{liststop}}%
    {\ifthenelse{\numexpr\value{listcount}+1<\value{liststop}}%
       {\addcomma\addspace}%
       {\ifthenelse{\value{liststop}>2}%
         {\addcomma\addspace\bibstring{and}\addspace}%
         {\addspace\bibstring{and}\addspace}}}%
       {}}

\newcommand*{\multilangdelim}{%
  \ifthenelse{\value{listtotal}<3}%
  {\addspace\bibstring{and}\addspace}%
  {\ifthenelse{\value{listcount}<\value{listtotal}}%
    {\addcomma\addspace}%
    {\addcomma\addspace\bibstring{and}\addspace}}}

\renewcommand*{\postnotedelim}{%
  \iftoggle{cms@shortnote}%
  {\iffieldequalstr{entrysubtype}{classical}%
    {\NumCheckSetup{\DeclareNumChars*{abcdeABCDE}}% Makes classical
      \iffieldpages{postnote}% test more accurate. See 17.253.
      {\addspace}%
      {\addcomma\addspace}}%
    {\addcomma\addspace}}% 16th ed -- no more volumes test.
  {\iftoggle{cms@fullnote}%
    {\ifthenelse{\(\ifentrytype{article}\OR
        \ifentrytype{review}\OR
        \ifentrytype{periodical}\OR
        \ifentrytype{suppperiodical}\)\AND\NOT
        \iffieldequalstr{entrysubtype}{magazine}}%
      {\addcolon\addspace}%
      {\addcomma\addspace}}%
    {\addcomma\addspace}}}%

\newcommand*{\postnotewrapper}{%
  \iftoggle{cms@modpostnote}%
  {\ifboolexpr{%
      test {\iffieldstart{postnote}{,}}%
      or
      test {\iffieldstart{postnote}{\bibrangessep}}%
    }%
    {\addcomma}% w/ or w/o \addspace?
    {\ifboolexpr{%
        test {\iffieldstart{postnote}{;}}%
        or
        test {\iffieldstart{postnote}{:}}%
        or
        test {\iffieldstart{postnote}{.}}%
      }%
      {}{\postnotedelim}}}%
  {\postnotedelim}}%

\newrobustcmd*{\iffieldstart}[2]{% Philipp Lehman's code, from
  \begingroup%                     comp.text.tex
  \edef\@tempa{%
    \long\def\noexpand\iffieldstart@i####1\detokenize{#2}####2}%
  \@tempa\@nil{\endgroup\ifblank{##1}}%
  \savefield*{#1}{\@tempa}%
  \expandafter\iffieldstart@i\detokenize
  \expandafter\expandafter\expandafter{%
    \expandafter\@tempa\detokenize{#2}}\@nil}

\newcommand*{\editordelim}{%
  \ifboolexpr{%
    test {\iffieldequalstr{editortype}{none}}%
    and
    not togl {cms@fullnote}%
  }%
  {\addperiod\addspace}%
  {\addcomma\addspace}}

\newcommand*{\lbx@cfromlang}{% Needed to eliminate "by" after "trans."
  \iffieldundef{userf}
  {\iffieldundef{origlanguage}
    {\unspace}
    {\bibstring{cfrom\thefield{origlanguage}}}}%
  {\unspace}}

\@ifpackagelater{biblatex}{2011/11/12}
{\renewcommand*{\lbx@fromlang}{%
    \iffieldundef{userf}
    {\iffieldundef{origlanguage}
      {\unspace}
      {\bibstring{from\thefield{origlanguage}}}}%
    {\unspace}}}
{\@ifpackagelater{biblatex}{2011/07/28}
  {\newcommand*{\lbx@fromlang}{%
      \iffieldundef{userf}
      {\iffieldundef{origlanguage}
        {\unspace}
        {\bibstring{from\thefield{origlanguage}}}}%
      {\unspace}}}%
  {\renewcommand*{\lbx@fromlang}{%
      \iffieldundef{userf}
      {\iffieldundef{origlanguage}
        {\unspace}
        {\bibstring{from\thefield{origlanguage}}}}%
      {\unspace}}}}

\renewcommand*{\lbx@lfromlang}{%
  \iffieldundef{userf}
  {\iffieldundef{origlanguage}
    {\unspace}
    {\biblstring{from\thefield{origlanguage}}}}%
  {\unspace}}

\renewcommand*{\lbx@sfromlang}{%
  \iffieldundef{userf}
  {\iffieldundef{origlanguage}
    {\unspace}
    {\bibsstring{from\thefield{origlanguage}}}}%
  {\unspace}}

%%%% Formatting macros, called both by cbx and bbx %%%%

\newbibmacro*{finentry}{%{\finentry} To make annotated bibliography
  \togglefalse{cms@switchdates}%
  \ifbibliography
    {\usebibmacro{entrytail}}
    {}%
  \finentry}

\newbibmacro*{book:xref+finentry}{%
  \iffieldundef{crossref}%
  {\iffieldundef{xref}%
    {}%
    {\iftoggle{cms@bookcitexref}%
      {}%
      {\ifboolexpr{
          test {\ifpunct}%
          or
          test {\ifpunctmark{*}}%
        }%
        {\bibhypertarget{\thefield{xref}}%
          {\cmsnoopcite{\thefield{xref}}}\nopunct}%
        {\bibhypertarget{\thefield{xref}}%
          {\cmsnoopcite{\thefield{xref}}}}}}}%
  {\iftoggle{cms@bookcitexref}%
    {}%
    {\ifboolexpr{
        test {\ifpunct}%
        or
        test {\ifpunctmark{*}}%
      }%
      {\bibhypertarget{\thefield{crossref}}%
        {\cmsnoopcite{\thefield{crossref}}}\nopunct}%
      {\bibhypertarget{\thefield{crossref}}%
        {\cmsnoopcite{\thefield{crossref}}}}}}}

\newbibmacro*{cite:xref+finentry}{%
  \iffieldundef{crossref}%
  {\iffieldundef{xref}%
    {}%
    {\iftoggle{cms@citecrossref}%
      {}%
      {\ifboolexpr{
          test {\ifpunct}%
          or
          test {\ifpunctmark{*}}%
        }%
        {\bibhypertarget{\thefield{xref}}%
          {\cmsnoopcite{\thefield{xref}}}\nopunct}%
        {\bibhypertarget{\thefield{xref}}%
          {\cmsnoopcite{\thefield{xref}}}}}}}%
  {\iftoggle{cms@citecrossref}%
    {}%
    {\ifboolexpr{
        test {\ifpunct}%
        or
        test {\ifpunctmark{*}}%
      }%
      {\bibhypertarget{\thefield{crossref}}%
        {\cmsnoopcite{\thefield{crossref}}}\nopunct}%
      {\bibhypertarget{\thefield{crossref}}%
        {\cmsnoopcite{\thefield{crossref}}}}}}}

\newbibmacro*{entrytail}{% From reading.bbx, for annotated bibliography
  \newunit\newblock
  \iftoggle{cms@annotation}%
    {\usebibmacro{annotation}%
     \newunit\newblock}
    {}}%

\newbibmacro*{author+holder}{%
  \ifnameundef{author}
    {}
    {\printnames{author}%
     \ifthenelse{\ifnameundef{holder}\OR
                 \ifnamesequal{author}{holder}}
       {}
       {\setunit{\addspace}%
        \printtext[parens]{\printnames{holder}}}}}

\renewbibmacro*{byauthor}{%
  \ifthenelse{\ifuseauthor\OR
              \ifnameundef{author}}
    {}
    {\bibstring{by}\addspace
     \printnames[byauthor]{author}}}

\newbibmacro*{byauthorpunct}{%
  \ifthenelse{\ifuseauthor\OR\ifnameundef{author}}%
  {\addperiod\addspace}%
  {\newcunit}}

\renewbibmacro*{bybookauthor}{%
  \ifnameundef{bookauthor}
    {}
    {\ifnamesequal{author}{bookauthor}
      {}
      {\bibstring{by}\addspace\printnames[default]{bookauthor}%
     \newcunit\newblock}}}

\newbibmacro*{editorpunct}{%
  \ifthenelse{\(\iffieldundef{booktitle}\AND%
    \iffieldundef{maintitle}\AND\iffieldundef{issuetitle}\)%
    \OR\iffieldsequal{booktitle}{title}%  Changed these for crossrefed
    \OR\iffieldsequal{maintitle}{title}}% entries.  Create problems?
  {\ifentrytype{video}% Change for Video type?  Appears
    {\newcunit\newblock}% to treat italicized title as booktitle in
    {\newunit\newblock}}% available examples.  Added issuetitle 0.9.9c.
  {\newcunit\newblock}}

\newbibmacro*{edition}{%
  \printfield{edition}%
    \clearfield{edition}}%

\newbibmacro*{inforaft}{%
  \ifnameundef{introduction}%
  {\ifnameundef{afterword}%
    {\ifnameundef{foreword}%
      {\printfield{type}}%
      {\bibstring{forewordto}%
        \clearname{foreword}}}% 16th ed.
    {\bibstring{afterwordto}%
      \clearname{afterword}}}%
  {\bibstring{introductionto}%
    \clearname{introduction}}}

\newbibmacro*{langlist:andothers}{%
  \ifthenelse{\value{listcount}=\value{liststop}\AND
              \ifmoreitems}
    {\ifnum\value{liststop}>1 \finalandcomma\fi
     \andmoredelim\bibstring{andmore}\bibrightbracket}
    {}}

\newbibmacro*{mag+news+author}{%
  \ifnameundef{author}%
  {\ifthenelse{\iffieldequals{journaltitle}{\bbx@lasthash}\AND\NOT
      \iffirstonpage}%
    {\bibnamedash\addperiod\addspace}%
    {\usebibmacro{journal+sub}%
      \setunit*{\addspace}%
      \printlist[periodplace]{location}%
      \savefield{journaltitle}{\bbx@lasthash}}}%
  {\ifuseauthor%
    {\usebibmacro{author}}%
    {}}}

\newbibmacro*{cmag+news+author}{%
  \ifnameundef{author}%
  {}% 16th ed.
  {\ifuseauthor%
    {\usebibmacro{author}}%
    {}}}

\newbibmacro*{type+inst+year}{%
  \printfield{type}
  \newcunit
  \printlist{institution}%
  \setunit*{\addcomma\space}%
  \usebibmacro{cmsyear}}

\newbibmacro*{institution+organization}{%
  \iflistundef{organization}%
  {\iflistundef{institution}%
    {}%
    {\printlist{institution}}}%
  {\printlist{organization}%
    \newcunit%
    \printlist{institution}}}

\newbibmacro*{bibauthor+org}{%
  \ifnameundef{author}%
  {\ifnameundef{editor}%
    {\iflistundef{organization}%
      {}%
      {\ifboolexpr{
          test {\iflistequals{organization}{\bbx@lasthash}}%
          and
          not test {\iffirstonpage}%
        }%
        {\bibnamedash\addperiod\addspace}%
        {\printlist{organization}%
          \savelist{organization}{\bbx@lasthash}}}}%
    {\usebibmacro{editor}}}%
  {\usebibmacro{author/editor}}}

\newbibmacro*{author+org}{%
  \ifnameundef{author}%
  {\ifnameundef{editor}%
    {\iflistundef{organization}%
      {}%
      {\printlist{organization}}}%
    {\usebibmacro{editor}}}%
  {\usebibmacro{author/editor}}}

\newbibmacro*{cbytypestrg}[2]{%
  \iffieldundef{#1type}
    {\bibstring{cby#2}}
    {\bibstring{cby\thefield{#1type}}}}

\newbibmacro*{cbyeditor}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{cbytypestrg}{editor}{editor}%
     \setunit{\addspace}%
     \printnames[byeditor]{editor}%
     \newcunit}%
  \usebibmacro{cbyeditorx}}

\newbibmacro*{cbyeditorx}{%
  \ifnameundef{editora}
    {}
    {\usebibmacro{cbytypestrg}{editora}{editor}%
     \setunit{\addspace}%
     \printnames[byeditora]{editora}%
     \newcunit}%
  \ifnameundef{editorb}
    {}
    {\usebibmacro{cbytypestrg}{editorb}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorb]{editorb}%
     \newcunit}%
  \ifnameundef{editorc}
    {}
    {\usebibmacro{cbytypestrg}{editorc}{editor}%
     \setunit{\addspace}%
     \printnames[byeditorc]{editorc}%
     \newcunit}}

\newbibmacro*{cbytranslator}{%
  \ifnameundef{translator}
  {}
  {\bibstring{cbytranslator}%
    \addspace
    \printnames[bytranslator]{translator}}}

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

\newbibmacro*{cbyredactor}{%
  \ifnameundef{redactor}
    {}
    {\bibstring{cbyredactor}\addspace
     \printnames[byredactor]{redactor}}}

\newbibmacro*{cwithcommentator}{%
  \ifnameundef{commentator}
    {}
    {\bibsstring{withcommentator}\addspace
     \printnames[withcommentator]{commentator}}}

\newbibmacro*{cwithannotator}{%
  \ifnameundef{annotator}
    {}
    {\bibsstring{withannotator}\addspace
     \printnames[withannotator]{annotator}}}

\newbibmacro*{cwithintroduction}{%
  \ifnameundef{introduction}
    {}
    {\bibstring{withintroduction}\addspace
     \printnames[withintroduction]{introduction}}}

\newbibmacro*{cwithforeword}{%
  \ifnameundef{foreword}
    {}
    {\bibstring{withforeword}\addspace
     \printnames[withforeword]{foreword}}}

\newbibmacro*{cwithafterword}{%
  \ifnameundef{afterword}
    {}
    {\bibstring{withafterword}\addspace
     \printnames[withafterword]{afterword}}}

\newbibmacro*{cbyeditor+others}{%
  \ifthenelse{\NOT\ifnameundef{editor}\AND
    \(\iffieldundef{editortype}\OR
    \iffieldequalstr{editortype}{editor}\)}
  {\def\@tempa{cbyeditor}%
    \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}\space
    \printnames[byeditor]{editor}%
    \clearname{editor}%
    \newcunit%
    \usebibmacro{cbyeditorx}}%
  {\usebibmacro{cbyeditor}}%
  \usebibmacro{cbytranslator+others}}

\newbibmacro*{cbytranslator+others}{%
  \ifnameundef{translator}
    {}
    {\def\@tempa{cbytranslator}%
      \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}%
     \newcunit}%
  \usebibmacro{cbycompiler+others}}

\newbibmacro*{cbycompiler+others}{%
  \ifnameundef{namec}
    {}
    {\def\@tempa{cbycompiler}%
     \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}%
     \newcunit}%
  \usebibmacro{cbyothers}}

\newbibmacro*{cbyothers}{%
  \usebibmacro{cbytranslator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cbycompiler}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cbyredactor}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithcommentator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithannotator}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithintroduction}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithforeword}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cwithafterword}}

\newbibmacro*{cms-in:}{% Fix for 0.9a compat.
  \iftoggle{cms@origpublished}%
  {}% Removed the cms@crspace test -- fixed a bug I had introduced
  {\bibstring{in}%
    \setunit{\addspace}}}

\newbibmacro*{bibxref-in:}{%
  \iffieldundef{volume}%
  {\ifcsdef{cbx@incollvol}%
    {\restorefield{volume}{\cbx@incollvol}\toggletrue{cms@xrefvol}%
      \ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}}%
      {}%
      \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
      {\printfield{volume}%
        \clearfield{volume}%
        \global\let\cbx@incollvol\undefined% Volume fix
        \printfield{part}%
        \clearfield{part}%
        \global\let\cbx@incollpart\undefined% Volume fix
        \setunit{\addspace}%
        \bibstring{ofseries}%
        \setunit{\addspace}}%
      {\usebibmacro{cms-in:}}}%
    {\iffieldundef{part}%
      {\ifcsdef{cbx@incollpart}%
        {\restorefield{part}{\cbx@incollpart}\toggletrue{cms@xrefpart}}%
        {}}%
      {}%
      \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
        \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
      {\printfield[xrefpart]{part}%
        \clearfield{part}%
        \global\let\cbx@incollpart\undefined% Volume fix
        \setunit{\addspace}%
        \bibstring{ofseries}%
        \setunit{\addspace}}%
      {\usebibmacro{cms-in:}}}}%
  {\iffieldundef{part}%
    {\ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}\toggletrue{cms@xrefpart}}%
      {}}%
    {}%
    \ifthenelse{\ifentrytype{mvbook}\OR\ifentrytype{mvcollection}\OR%
      \ifentrytype{mvproceedings}\OR\ifentrytype{mvreference}}%
    {\printfield{volume}%
      \clearfield{volume}%
      \global\let\cbx@incollvol\undefined% Volume fix
      \printfield{part}%
      \clearfield{part}%
      \global\let\cbx@incollpart\undefined% Volume fix
      \setunit{\addspace}%
      \bibstring{ofseries}%
      \setunit{\addspace}}%
    {\usebibmacro{cms-in:}}}}%

\newbibmacro*{chapincoll}{%
  \iffieldundef{chapter}%
  {}
  {\printfield{chapter}\addspace%
    \clearfield{chapter}}}

\newbibmacro*{xrefchapincoll}{%
  \iffieldundef{chapter}%
  {\printtext{\relax}}
  {\printfield{chapter}\addspace%
    \clearfield{chapter}}}

\newbibmacro*{chapinscore}{%
  \iffieldundef{chapter}%
  {\ifthenelse{\ifentrytype{music}% 16th ed.
      \AND\NOT\iffieldundef{booktitle}}%
    {\bibstring{on}\setunit{\addspace}}%
    {}}
  {\printfield{chapter}%
    \addspace\bibstring{of}\setunit{\addspace}%
    \clearfield{chapter}}}

\newbibmacro*{caddendum}{% New macros for 16th ed. field exclusion
  \ifboolexpr{%
    togl {cms@addendum}%
    and
    not test {\iffieldundef{addendum}}%
  }%
  {\newcunit\printfield{addendum}}%
  {}}%

\newbibmacro*{cnotefield}{%
  \iftoggle{cms@notefield}%
  {\printfield{note}}%
  {}}%

\newbibmacro*{cser+num}{%
  \iftoggle{cms@bookseries}%
  {\printfield{series}%
    \printfield[sernum]{number}}%
  {}}%

\newbibmacro*{ser+num}{%
  \printfield{series}%
  \printfield[sernum]{number}}

\newbibmacro*{music+origdate}{%
  \iftoggle{cms@reprint}% 16th ed.
  {}%
  {\iffieldundef{origyear}%
    {}%
    {\usebibmacro{cmsorigdate}}}}% Date fix

\newbibmacro*{music+eventdate}{%
  \iffieldundef{eventyear}%
  {}%
  {\printeventdate}}% Date fix

\newbibmacro*{ctitle+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}%
  \setunit{\addcomma\addspace}\newblock%
  \printfield{titleaddon}}%
%  \setunit{\addspace}}%
%  \usebibmacro{language+transtitle}%
%  \setunit*{\addcomma}\newblock}

\newbibmacro*{citaltitle+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}%
  \newcunit\newblock%
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newcunit\newblock}

\newbibmacro*{title+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}%
  \newunit%\setunit{\addspace}\newblock%
  \printfield{titleaddon}}%
%  \setunit{\addspace}}%
%  \usebibmacro{language+transtitle}%
%  \newunit\newblock}

\newbibmacro*{italtitle+stitle}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}%
  \newunit\newblock%
  \printfield{titleaddon}%
  \setunit{\addspace}%
  \usebibmacro{language+transtitle}%
  \newunit\newblock}

\newbibmacro*{mag+news+title}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
       \printfield[noformat]{title}%
       \setunit{\addcolon\addspace}%
       \printfield[noformat]{subtitle}}%
     \newunit%\setunit{\addcomma\addspace}
     \printfield{titleaddon}%
     }%\newcunit\newblock}

\newbibmacro*{cmag+news+title}{%
  \printtext[title]{%:\thefield{entrytype}]{%(Changed for 0.7 to work)
       \printfield[noformat]{title}%
       \setunit{\addcolon\addspace}%
       \printfield[noformat]{subtitle}}%
     \setunit{\addcomma\addspace}%
     \printfield{titleaddon}%
     }%\newcunit\newblock}

\newbibmacro*{language+transtitle}{%
  \iffieldundef{usere}%
  {\printlist[][-\value{listtotal}]{language}}%
  {\printfield{usere}}}

\newbibmacro*{issuetitle}{%
  \iffieldundef{issuetitle}%
  {}
  {\ifthenelse{\ifentrytype{article}\OR%
      \ifentrytype{review}\OR%
      \ifentrytype{suppperiodical}}% This test is for
    {\usebibmacro{cms-in:}}% periodical entries
    {}%
    \printtext[issuetitle]{%
      \printfield[noformat]{issuetitle}%
      \setunit{\addcolon\addspace}%
      \printfield[noformat]{issuesubtitle}}}}

\newbibmacro*{btitle+bstitle}{%
  \iffieldundef{booktitle}
  {}
  {\ifthenelse{\ifentrytype{audio}\OR\ifentrytype{music}\OR%
      \ifentrytype{video}}%
    {}%
    {\usebibmacro{cms-in:}}%
    \printtext[booktitle]{%
      \printfield[noformat]{booktitle}%
      \setunit{\addcolon\addspace}%
      \printfield[noformat]{booksubtitle}}%
    \newcunit
    \printfield{booktitleaddon}%
    \setunit*{\addcomma\addspace}}}

\newbibmacro*{publ+loc+year}{% Revised for reprint
  \ifboolexpr{
    togl {cms@reprint}%
    and
    not test {\ifentrytype{video}}%
  }%
  {\bibstring{reprint}%
    \newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{publisher}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
}

\newbibmacro*{origpubl+loc+year}{% 16th ed.
  \printlist{origlocation}%
  \iflistundef{origpublisher}%
  {\setunit*{\addcomma\addspace}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{origpublisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{cmsorigdate}%
}

\newbibmacro*{howpubl+loc+year}{% Revised for reprint
  \usebibmacro{cmsorigdate}%
  \reprintpunct%
  \iftoggle{cms@reprint}%
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iffieldundef{howpublished}%
  {\setunit*{\addcomma\space}}%
  {\setunit*{\addcolon\space}}%
  \printfield{howpublished}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
}

\newbibmacro*{inst+loc+year}{% Revised for reprint
  \usebibmacro{origpubl+loc+year}%{cmsorigdate}% 16th ed.
  \reprintpunct%
  \iftoggle{cms@reprint}%
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{institution}%
  {\setunit*{\addcomma\space}}%
  {\setunit*{\addcolon\space}}%
  \printlist{institution}%
  \setunit*{\addcomma\space}%
  \usebibmacro{date}%
}%

\newbibmacro*{cpubl+loc+year}{% Revised for reprint
  \ifboolexpr{
    test {\iflistundef{location}}%
    and
    test {\iflistundef{publisher}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@reprint}%
  }%
  {}%
  {\setunit{\addspace}%
    \printtext[parens]{%
      \usebibmacro{origpubl+loc+year}%{cmsorigdate}%\printfield{origyear}%
      \setunit*{\addsemicolon\addspace}%
      \ifboolexpr{
        togl {cms@reprint}%
        and
        not test{\ifentrytype{video}}%
      }%
      {\bibsstring{reprint}%
        \newcunit}%
      {}%
      \printlist{location}%
      \iflistundef{publisher}
      {\setunit*{\addspace}}
      {\setunit*{\addcolon\space}}%
      \printlist{publisher}%
      \setunit{\addcomma\space}%
      \usebibmacro{date}}}}%

\newbibmacro*{cpubletter+loc+year}{%
  \ifboolexpr{
    test {\iflistundef{location}}%
    and
    test {\iflistundef{publisher}}%
    and
    test {\iffieldundef{year}}%
  }%
  {}%
  {\setunit{\addspace}%
    \printtext[parens]{%
      \printlist{location}%
      \iflistundef{publisher}
      {\setunit*{\addspace}}
      {\setunit*{\addcolon\space}}%
      \printlist{publisher}%
      \setunit{\addcomma\space}%
      \usebibmacro{date}}}}% Changed for 0.9

\newbibmacro*{originally+published+as}{% Punctuation fix now in 
  \iffieldundef{userf}%                  \origfullcite for 0.8e. 
  {\iffieldundef{reprinttitle}%
    {}
    {\bibstring{origpublin}%
      \origpublcite{\thefield{reprinttitle}}%
      \newunit}}
  {\iffieldundef{origlanguage}%
    {\bibstring{origpub}%
      \origfullcite{\thefield{userf}}
      \newunit}%
    {\iftoggle{cms@postposit}%
      {\bibstring{origedition}%
        \setunit{\addspace}%
        \printfield[edlang]{origlanguage}%
        \addcolon%
        \origfullcite{\thefield{userf}}%
        \newunit}%
      {\printfield[edlang]{origlanguage}%
        \setunit{\addspace}%
        \bibstring{origedition}%
        \origfullcite{\thefield{userf}}
        \newunit}}}}

\newbibmacro*{org+publ+loc+year}{% What was wrong with \ifthenelse here?
  \usebibmacro{origpubl+loc+year}%{cmsorigdate}% 16th ed.
  \reprintpunct%
  \iftoggle{cms@reprint}% Revised for reprint
  {\reprint\newcunit}%
  {}%
  \printlist{location}%
  \iflistundef{organization}%
  {\iflistundef{publisher}%
    {\setunit*{\addcomma\addspace}}%
    {\setunit*{\addcolon\addspace}}}%
  {\setunit*{\addcolon\addspace}}%
  \printlist{organization}%
  \setunit*{\addcomma\space}%
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}}

\newbibmacro*{year+in+parens}{%
  \iffieldundef{volume}%
  {noformat}%
  {parens}}

\newbibmacro*{cjournal+issue+year+pages}{%
  \usebibmacro{cjournal+ser+vol+num}%
  \ifboolexpr{% 16th ed.
    test {\iffieldundef{issue}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@switchdates}%
  }%
  {\iffieldundef{number}%
    {\ifthenelse{\iffieldundef{pagination}\AND%
        \iffieldundef{bookpagination}}%
      {\setunit{\postvolpunct}}%
      {\setunit{\addcolon\addspace}}}%
    {\addcomma\addspace}}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{number}}% 16th ed.
    {\newcunit%
      \iffieldundef{issue}
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}%
      \addcomma\addspace}%
    {\setunit{\addspace}%
    \printtext[parens]{% parens is the default here
      \iffieldundef{issue}
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}}}}

\newbibmacro*{cperiodical+issue+year+pages}{% For periodicals,
  \usebibmacro{cperiodical+ser+vol+num}% subtype article
  \ifboolexpr{% 16th ed.
    test {\iffieldundef{issue}}%
    and
    test {\iffieldundef{year}}%
    and
    not togl {cms@switchdates}%
  }%
  {\iffieldundef{number}%
    {\ifthenelse{\iffieldundef{pagination}\AND%
        \iffieldundef{bookpagination}}%
      {\setunit{\postvolpunct}}%
      {\setunit{\addcolon\addspace}}}%
    {\addcomma\addspace}}%
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{number}}% 16th ed.
    {\newcunit%
      \iffieldundef{issue}
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}%
      \addcomma\addspace}%
    {\setunit{\addspace}%
    \printtext[parens]{% parens is the default here
      \iffieldundef{issue}
      {\usebibmacro{number+or+month}}%
      {\printfield{issue}%
        \setunit{\addspace}%
        \usebibmacro{cmsyear}}}}}}

\newbibmacro*{letter+date}{% New for 0.9
  \iflistundef{origlocation}%
  {}%
  {\printlist{origlocation}%
    \newcunit\newblock}%
  \iftoggle{cms@switchdates}%
  {\ifthenelse{\iffieldundef{year}\AND\iffieldundef{month}}%
    {}%
    {\cms@datelongalt}}%
  {\ifthenelse{\iffieldundef{origyear}\AND\iffieldundef{origmonth}}%
    {}%
    {\cms@datelong}}}

\newbibmacro*{unpubl+letter+date}{% For Misc entries
  \iflistundef{origlocation}%
  {}%
  {\printlist{origlocation}%
    \newcunit\newblock}%
  \iftoggle{cms@switchdates}%
  {\ifthenelse{\iffieldundef{year}\AND\iffieldundef{month}}%
    {}%
    {\cms@datelongalt}}%
  {\ifthenelse{\iffieldundef{origyear}\AND\iffieldundef{origmonth}}%
    {\printdate}% For interviews and other dated non-letters.
    {\cms@datelong}}}

\newbibmacro*{pubstate}{%
  \iftoggle{cms@reprint}%
  {\iftoggle{cms@switchdates}%
    {\iffieldundef{year}%
      {}%
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printdate}}}%
    {\iffieldundef{origyear}%
      {}
      {\printtext{% 16th ed.
          \usebibmacro{choosepubstring}%
          \printorigdate}}}}%
  {}}%

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

\renewbibmacro*{date}{% New for 0.9
  \iftoggle{cms@switchdates}%
  {\printorigdate}%
  {\printdate}}

\newbibmacro{cite:xref+date}{%
  \ifboolexpr{
    togl {cms@omitxrefdate}%
    or
    togl {cms@bookcitexref}%
    or
    test {\iffieldundef{crossref}}%
    or
    test {\iffieldundef{maintitle}}%
    or
    ((
    test {\iffieldundef{year}}%
    or
    togl {cms@switchdates}%
    )
    and
    (test {\iffieldundef{origyear}}%
    or
    not togl {cms@switchdates}%
    ))
    or
    not test {\ifentryseen{\thefield{crossref}}}%
  }
  {\ifboolexpr{
      togl {cms@omitxrefdate}%
      or
      togl {cms@bookcitexref}%
      or
      test {\iffieldundef{xref}}%
      or
      test {\iffieldundef{maintitle}}%
      or
      ((
      test {\iffieldundef{year}}%
      or
      togl {cms@switchdates}%
      )
      and
      (test {\iffieldundef{origyear}}%
      or
      not togl {cms@switchdates}%
      ))
      or
      not test {\ifentryseen{\thefield{xref}}}%
    }
    {}%
    {\printtext[parens]{\usebibmacro{date}}}}%
  {\printtext[parens]{\usebibmacro{date}}}}

\newbibmacro*{cmsorigdate}{% New for 0.9
  \iftoggle{cms@switchdates}%
  {\printdate}%
  {\printorigdate}}

\newbibmacro*{cmsyear}{%
  \iftoggle{cms@switchdates}%
  {\printfield{origyear}}%
  {\printfield{year}}}

\newbibmacro*{number+or+month}{%
  \iffieldundef{number}%
  {\usebibmacro{date}}%
  {\iftoggle{cms@numbermonth}%
    {\usebibmacro{date}}%
    {\usebibmacro{cmsyear}}}}

\newcommand*{\cms@datelong}{% Modified for 0.9
  \iffieldundef{origmonth}%
  {\printfield{origyear}}%
  {\printfield[letterday]{origday}\setunit*{\nobreakspace}% Bug fix
    \mkbibmonth{\thefield{origmonth}}\setunit{\nobreakspace}%
    \printfield{origyear}}}%

\newcommand*{\cms@datelongalt}{% Modified for 0.9
  \iffieldundef{month}%
  {\printfield{year}}%
  {\printfield[letterday]{day}\setunit*{\nobreakspace}%
    \mkbibmonth{\thefield{month}}\setunit{\nobreakspace}%
    \printfield{year}}}%

\newcommand*{\letterdatelong}{% Modified for 0.9
  \iftoggle{cms@switchdates}% This one for users
  {\iffieldundef{year}% Previous two for internal use
    {}%
    {\iffieldundef{month}%
      {\printfield{year}}%
      {\printfield[letterday]{day}\setunit*{\nobreakspace}%
        \mkbibmonth{\thefield{month}}\setunit{\nobreakspace}%
        \printfield{year}}}}%
  {\iffieldundef{origyear}%
    {}%
    {\iffieldundef{origmonth}%
      {\printfield{origyear}}%
      {\printfield[letterday]{origday}\setunit*{\nobreakspace}%
        \mkbibmonth{\thefield{origmonth}}\setunit{\nobreakspace}%
        \printfield{origyear}}}}}%

\newbibmacro*{cjournal+ser+vol+num}{%
  \usebibmacro{journal+sub}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newcunit
      \printfield[jourser]{series}%
      \newcunit}%\setunit*{\addspace}?
  \printfield[jourvol]{volume}%
  \setunit{\addcomma\addspace}% need * here?
  \printfield[journum]{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
  \newunit}

\newbibmacro*{cperiodical+ser+vol+num}{% For periodical entries,
  \printtext[title]{% article subtype
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}% 
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newcunit
      \printfield[jourser]{series}%
      \newcunit}%\setunit*{\addspace}?
  \printfield[jourvol]{volume}%
  \setunit{\addcomma\addspace}% need * here?
  \printfield[journum]{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
  \newunit}

\newbibmacro*{journal+sub}{%
  \iffieldundef{journaltitle}
    {}
    {\printtext[journaltitle]{%
       \printfield[noformat]{journaltitle}%
       \setunit{\addcolon\addspace}%
       \printfield[noformat]{journalsubtitle}}}}

\newbibmacro*{cite+doi+url}{% 16th ed.
  \iffieldundef{urlyear}
  {}
  {\printurldate}% Date fix
  \newcunit\newblock
  \iftoggle{cms@doionly}%
  {\iffieldundef{doi}%
    {}%
    {\printfield{doi}%
      \clearfield{url}}}%
  {\iftoggle{cms@doi}%
    {\printfield{doi}}%
    {}}%
  \newcunit\newblock
  \iftoggle{cms@eprint}%
  {\usebibmacro{eprint}}%
  {}%
  \newcunit\newblock
  \iftoggle{cms@url}%
  {\printfield{url}}%
  {}}%

\newbibmacro*{chap+pag}{%
  \printfield{chapter}%
  \setunit*{\addcomma\space}%
  \printfield{pages}}

\newbibmacro*{mag+news+date}{% 16th ed.
  \iftoggle{cms@fullnote}%
  {\usebibmacro{mag+date+issue}}%
  {\ifnameundef{author}%
    {\usebibmacro{date+issue}}%
    {\usebibmacro{mag+date+issue}}}}

\newbibmacro*{date+issue}{%
  \iffieldundef{issue}
  {\iffieldundef{number}%
    {\usebibmacro{date}}%
    {\iftoggle{cms@numbermonth}% For exclusion of month
      {\usebibmacro{date}}%
      {\usebibmacro{cmsyear}}%
      \setunit{\addcomma\addspace}%
      \printfield[journum]{number}}}%
  {\printfield{issue}%
    \setunit{\addspace}%
    \usebibmacro{cmsyear}}}

\newbibmacro*{mag+date+issue}{%
  \usebibmacro{journal+sub}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \newcunit\newblock
  \printfield{usera}% For network ID and possible section of newspaper.
  \newcunit\newblock
  \usebibmacro{date+issue}}

\newbibmacro*{periodical+date+issue}{% For periodical type &
  \printtext[title]{% magazine subtype
    \printfield[noformat]{title}%
    \setunit{\addcolon\addspace}%
    \printfield[noformat]{subtitle}}%
  \setunit*{\addspace}%
  \printlist[periodplace]{location}%
  \newcunit\newblock
  \printfield{usera}% For network ID and possible section of newspaper.
  \newcunit\newblock
  \usebibmacro{date+issue}}

\newbibmacro*{cmtitle+mstitle+vol+part+title+stitle}{%
  \iffieldundef{maintitle}
  {}
  {\ifthenelse{\iffieldundef{volume}\AND\iffieldundef{part}}%
    {\usebibmacro{cms-in:}%
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}}}

\newbibmacro*{cmtitle+mstitle+vol+part+btitle+bstitle}{%
  \usebibmacro{btitle+bstitle}%
  \iffieldundef{maintitle}
  {}
  {\ifthenelse{\(\iffieldundef{volume}\AND\iffieldundef{part}\)\OR%
      \(\iffieldundef{booktitle}\AND\NOT\ifentrytype{bookinbook}\)}%
    {\iffieldundef{booktitle}% Fix for origpublin ???
      {\usebibmacro{cms-in:}}%
      {\bibstring{in}\setunit{\addspace}}%
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}%
      \toggletrue{cms@vol}}% InIn fix
    {\toggletrue{cms@usedvol}%
      \printfield{volume}%
      \printfield{part}%
      \setunit{\addspace}
      \bibstring{ofseries}%
      \setunit{\addspace}
      \printtext[maintitle]{%
        \printfield[noformat]{maintitle}%
        \setunit{\addcolon\addspace}%
        \printfield[noformat]{mainsubtitle}}%
      \newcunit
      \printfield{maintitleaddon}}}}

\newbibmacro*{backref+check}{%
  \ifbibliography%
  {\backtrackerfalse}%
  {}}%

\newbibmacro*{cite:postnote}{%
  \iftoggle{cms@loccit}%
  {}%
  {\usebibmacro{postnote}}}

\newbibmacro*{semel:postnote}{% Fix to print postnote only once
  \printfield{postnote}% Old form broke \ifloccit
  \global\let\cms@pnsaved\abx@field@postnote%
  \global\let\abx@field@postnote\undefined%
  \AtNextCitekey{\ifciteibid{}{\global\let\cms@pnsaved\undefined}}}%

\renewbibmacro*{postnote}{%
  \iftoggle{cms@fullnote}%
  {\global\togglefalse{cms@shortnote}%
    \global\togglefalse{cms@fullnote}}
  {\iftoggle{cms@printshhand}
    {\iffieldundef{postnote}%
      {\iffieldundef{shorthand}
        {\global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}
        {\usebibmacro{cms:shorthandintro}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}}
      {\iffieldundef{shorthand}
        {\postnotewrapper%delim%
          \usebibmacro{semel:postnote}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}
        {\postnotewrapper%delim%
          \usebibmacro{semel:postnote}%
          \usebibmacro{cms:shorthandintro}%
          \global\togglefalse{cms@printshhand}%
          \global\togglefalse{cms@shortnote}%
          \global\togglefalse{cms@fullnote}}}}
    {\iffieldundef{postnote}%
      {\global\togglefalse{cms@shortnote}%
        \global\togglefalse{cms@fullnote}}
      {\postnotewrapper%delim%
        \usebibmacro{semel:postnote}%
        \global\togglefalse{cms@shortnote}%
        \global\togglefalse{cms@fullnote}}}}}%

\newbibmacro*{fullpostnote}{%
  \iffieldundef{postnote}%
  {\iffieldundef{chapter}%
    {\iffieldundef{pages}%
      {}%
      {\postnotedelim%
        \printfield{pages}}}%
    {\postnotedelim%
      \printfield{chapter}}}%
  {\postnotewrapper%delim% Don't need \ifbibliography test w/ following
    \usebibmacro{semel:postnote}}}

\newbibmacro*{volfullpostnote}{%
  \iftoggle{cms@postvol}%
  {\ifboolexpr{(
      test {\iffieldundef{volume}}%
      and
      test {\iffieldundef{part}}%
      )
      or
      togl {cms@usedvol}%
    }%
    {\usebibmacro{fullpostnote}}%
    {\iffieldundef{postnote}%
      {\iffieldundef{chapter}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}%
            \printfield{part}}%
          {\iffieldundef{part}%
            {\ifthenelse{\iffieldnums{pages}\AND%
                \iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
              {\newcunit\printfield[default]{volume}%
                \postvolpunct%
                \printfield{pages}}%
              {\newcunit\printfield{volume}%
                \addcomma\addspace%
                \printfield{pages}}}%
            {\newcunit\printfield{volume}%
              \printfield{part}%
              \addcomma\addspace%
              \printfield{pages}}}}%
        {\newcunit\printfield{volume}%
          \printfield{part}%
          \newcunit
          \printfield{chapter}}}%
      {\iffieldundef{part}%
        {\ifthenelse{\iffieldnums{postnote}\AND%
            \iffieldundef{pagination}\AND\iffieldnums{volume}}%
          {\newcunit\printfield[default]{volume}%
            \postvolpunct%
            \usebibmacro{semel:postnote}}%
          {\newcunit\printfield{volume}%
            \addcomma\addspace%
            \usebibmacro{semel:postnote}}}%
        {\newcunit\printfield{volume}%
          \printfield{part}%
          \addcomma\addspace%
          \usebibmacro{semel:postnote}}}}}%
  {\usebibmacro{fullpostnote}}%
  \global\togglefalse{cms@usedvol}}%

\newbibmacro*{volume+or+volumes}{% Volume fix (modified)
  \ifboolexpr{ (
    test {\iffieldundef{maintitle}}%
    or
    togl {cms@vol}%
    )
    and
    not togl {cms@postvol}%
    and
    not togl {cms@usedvol}%
  }%
  {\global\togglefalse{cms@vol}%
    \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}}%
      or
      togl {cms@usedvol}%
      )
    }%
    {\global\togglefalse{cms@vol}}%
    {\global\togglefalse{cms@vol}%
      \printfield{volumes}}}}

\newbibmacro*{crossref:volume+postnote}{%
  \ifcsdef{cbx@incollpgn}%
  {\restorefield{pagination}{\cbx@incollpgn}}%
  {}%
  \ifcsdef{cbx@incollbkpgn}%
  {\restorefield{bookpagination}{\cbx@incollbkpgn}}%
  {}%
  \iffieldundef{volume}% Volume fix (unfinished)
  {\ifcsdef{cbx@incollvol}%
    {\restorefield{volume}{\cbx@incollvol}%
      \ifcsdef{cbx@incollpart}{\restorefield{part}{\cbx@incollpart}}{}%
      \iffieldundef{postnote}%
      {\ifcsdef{cbx@incollpages}%
        {\restorefield{pages}{\cbx@incollpages}%
          \usebibmacro{pages+cref+print}}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}\printfield{part}}%
          {\usebibmacro{pages+cref+print}}}}%
      {\usebibmacro{postnote+cref+print}}}%
    {\iffieldundef{part}%
      {\ifcsdef{cbx@incollpart}%
        {\restorefield{part}{\cbx@incollpart}%
          \iffieldundef{postnote}%
          {\ifcsdef{cbx@incollpages}%
            {\restorefield{pages}{\cbx@incollpages}%
              \usebibmacro{pages+cref+print}}%
            {\iffieldundef{pages}%
              {\newcunit\printfield{volume}\printfield{part}}%
              {\usebibmacro{pages+cref+print}}}}%
          {\usebibmacro{postnote+cref+print}}}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{fullpostnote}}%
          {\usebibmacro{fullpostnote}}}}%
      {\iffieldundef{postnote}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{pages+cref+print}}%
          {\iffieldundef{pages}%
            {\newcunit\printfield{volume}\printfield{part}}%
            {\usebibmacro{pages+cref+print}}}}%
        {\usebibmacro{postnote+cref+print}}}}}%
  {\iffieldundef{part}%
    {\ifcsdef{cbx@incollpart}%
      {\restorefield{part}{\cbx@incollpart}}%
      {}}%
    {}%
    \iffieldundef{maintitle}% More elaborate test ???
    {\iffieldundef{postnote}%
      {\ifcsdef{cbx@incollpages}%
        {\restorefield{pages}{\cbx@incollpages}%
          \usebibmacro{pages+cref+print}}%
        {\iffieldundef{pages}%
          {\newcunit\printfield{volume}\printfield{part}}%
          {\usebibmacro{pages+cref+print}}}}%
      {\usebibmacro{postnote+cref+print}}}%
    {\ifboolexpr{
        test {\ifcsdef{cbx@incollvol}}%
        and
        (
        not test {\iffieldequalcs{volume}{cbx@incollvol}}%
        or
        togl {cms@xrefvol}% Necessary ???
        )
      }%
      {\restorefield{volume}{\cbx@incollvol}%
        \iffieldundef{part}%
        {\ifcsdef{cbx@incollpart}{\restorefield{part}{\cbx@incollpart}}{}}%
        {\ifboolexpr{
            test {\ifcsdef{cbx@incollpart}}%
            and
            (
            not test {\iffieldequalcs{part}{cbx@incollpart}}%
            or
            togl {cms@xrefpart}%
            )
          }%
          {\clearfield{part}\restorefield{part}{\cbx@incollpart}}%
          {\clearfield{part}}}%
        \iffieldundef{postnote}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{pages+cref+print}}%
          {\iffieldundef{pages}%
            {\newcunit\printfield{volume}\printfield{part}}%
            {\usebibmacro{pages+cref+print}}}}%
        {\usebibmacro{postnote+cref+print}}}%
      {\ifboolexpr{
          test {\ifcsdef{cbx@incollpart}}%
          and
          (
          not test {\iffieldequalcs{part}{cbx@incollpart}}%
          or
          togl {cms@xrefpart}%
          )
        }
        {\iffieldundef{postnote}%
          {\ifcsdef{cbx@incollpages}%
            {\restorefield{pages}{\cbx@incollpages}%
              \printfield{part}\newcunit\printfield{pages}}%
            {\iffieldundef{pages}%
              {\printfield{part}}%
              {\printfield{part}\newcunit\printfield{pages}}}}%
          {\printfield{part}\newcunit\usebibmacro{semel:postnote}}}%
        {\ifcsdef{cbx@incollpages}%
          {\restorefield{pages}{\cbx@incollpages}%
            \usebibmacro{fullpostnote}}%
          {\usebibmacro{fullpostnote}}}}}}}%

\newbibmacro*{pages+cref+print}{% Reusable chunk for above
  \iffieldundef{part}%
  {\ifthenelse{\iffieldnums{pages}\AND%
      \iffieldundef{bookpagination}\AND\iffieldnums{volume}}%
    {\newcunit\printfield[default]{volume}%
      \postvolpunct%
      \printfield{pages}}%
    {\newcunit\printfield{volume}%
      \addcomma\addspace%
      \printfield{pages}}}%
  {\newcunit\printfield{volume}%
    \printfield{part}%
    \addcomma\addspace%
    \printfield{pages}}}

\newbibmacro*{postnote+cref+print}{% Reusable chunk for above
  \iffieldundef{part}%
  {\ifthenelse{\iffieldnums{postnote}\AND%
      \iffieldundef{pagination}\AND\iffieldnums{volume}}%
    {\newcunit\printfield[default]{volume}%
      \postvolpunct%
      \usebibmacro{semel:postnote}}%
    {\newcunit\printfield{volume}%
      \addcomma\addspace%
      \usebibmacro{semel:postnote}}}%
  {\newcunit\printfield{volume}%
    \printfield{part}%
    \addcomma\addspace%
    \usebibmacro{semel:postnote}}}

\newbibmacro*{inreffullpostnote}{%
  \global\togglefalse{cms@usedvol}%
  \iffieldundef{postnote}%
  {\iffieldundef{chapter}%
    {\iffieldundef{pages}%
      {\newcunit%\addcomma\addspace% Change to axe spurious comma
        \printlist[][-\value{listtotal}]{lista}}%
      {\postnotedelim%
        \printfield{pages}}}%
    {\postnotedelim%
      \printfield{chapter}}}%
  {\postnotewrapper%delim%
    \usebibmacro{semel:postnote}}}

\newbibmacro*{xrefprenote}{%
  \iffieldundef{volume}{}{\savefield{volume}{\cbx@incollvol}}%
  \iffieldundef{pages}{}{\savefield{pages}{\cbx@incollpages}}%
  \iffieldundef{part}{}{\savefield{part}{\cbx@incollpart}}%
  \iffieldundef{pagination}{}{\savefield{pagination}{\cbx@incollpgn}}%
  \iffieldundef{bookpagination}{}{\savefield{bookpagination}%
    {\cbx@incollbkpgn}}% The next line saves the child's backrefs
  \iflistundef{pageref}{}{\savelist{pageref}{\cbx@incollpgref}}}%

\newbibmacro*{xrefpostnote}{%
  \ifcsdef{cbx@incollpgref}% Here we print and clear the child's
  {\restorelist{pageref}{\cbx@incollpgref}% backrefs
  \newunit%
  \usebibmacro{pageref}%
  \global\let\cbx@incollpgref\undefined}%
  {}%
  \togglefalse{cms@xrefvol}%
  \togglefalse{cms@xrefpart}%
  \global\togglefalse{cms@usedvol}%
  \global\let\cbx@incollvol\undefined% Volume fix
  \global\let\cbx@incollpages\undefined%
  \global\let\cbx@incollpart\undefined%
  \global\let\cbx@incollpgn\undefined%
  \global\let\cbx@incollbkpgn\undefined}

\newbibmacro*{hlprenote}{% Removes spurious comma after prenote in
  \iffieldundef{prenote}%  \headlessfullnote citations.
    {}
    {\printfield{prenote}%
     \nopunct}}% Do we need \unspace here?

\newbibmacro*{hlcprenote}{% As previous, but for generalized \headlesscite
  \iffieldundef{prenote}% command, rather than \headlessfullcite.
    {\bibsentence}% Needed for Ibid to be capitalized.
    {\printfield{prenote}%
      \ifboolexpr{%
        test {\ifciteseen}%
        or
        togl {cms@allshort}%
      }%
      {\addspace}%
      {\nopunct}}}% Do we need \unspace here?

\newbibmacro*{journalprenote}{%
  \iffieldundef{prenote}%
  {\bibsentence}%
  {\usebibmacro{prenote}}}

\newbibmacro*{choose+surname}{%
  \ifciteseen%
  {}
  {\ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
    {\printnames{labelname}%
      \clearname{author}}%
  {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{namea}}%
    {\printnames[labelname]{namea}\newcunit%
      \usebibmacro{parteditstrg}}%
    {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}%
      {\printnames{labelname}\newcunit%
        \usebibmacro{editstrg}}%
      {\ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{nameb}}%
        {\printnames[labelname]{nameb}\newcunit%
          \usebibmacro{parttransstrg}}%
        {\ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}%
          {\printnames{labelname}\newcunit%
            \usebibmacro{transstrg}}%
          {\ifboolexpr{%
              not test {\ifnameundef{namec}}%
              and
              togl {cms@usecompiler}%
            }%
            {\printnames[labelname]{namec}\newcunit%
              \usebibmacro{compilestrg}}%
            {}}}}}}}}%

\newbibmacro*{choose+labelname}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
  {\printnames{labelname}}%
  {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{namea}}%
    {\printnames[labelname]{namea}}%
    {\ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}%
      {\printnames{labelname}}%
      {\ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{nameb}}%
        {\printnames[labelname]{nameb}}%
        {\ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}%
          {\printnames{labelname}}%
          {\ifboolexpr{%
              not test {\ifnameundef{namec}}%
              and
              togl {cms@usecompiler}%
            }%
            {\printnames[labelname]{namec}}%
            {}}}}}}}%

\@ifpackagelater{biblatex}{2012/11/20}% for biblatex 2.4
{\DeclareLabelname{\field{shortauthor} \field{author}%
    \field{shorteditor} \field{namea} \field{editor}%
    \field{nameb} \field{translator} \field{namec}}}
{\DeclareLabelname{shortauthor,author,shorteditor,namea,%
    editor,nameb,translator,namec}}

\DeclareDataInheritance{collection}{suppcollection}{%
  \inherit{title}{title}
  \inherit{subtitle}{subtitle}
  \inherit{titleaddon}{titleaddon}}

\DeclareDataInheritance{mvbook}{incollection}{%
  \inherit{title}{maintitle}
  \inherit{subtitle}{mainsubtitle}
  \inherit{titleaddon}{maintitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{book,collection}{letter}{%
  \inherit{title}{booktitle}
  \inherit{subtitle}{booksubtitle}
  \inherit{titleaddon}{booktitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{book}{incollection}{%
  \inherit{title}{booktitle}
  \inherit{subtitle}{booksubtitle}
  \inherit{titleaddon}{booktitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{mvbook,mvcollection}{letter}{%
  \inherit{title}{maintitle}
  \inherit{subtitle}{mainsubtitle}
  \inherit{titleaddon}{maintitleaddon}
  \noinherit{shorttitle}
  \noinherit{sorttitle}
  \noinherit{indextitle}
  \noinherit{indexsorttitle}
}

\DeclareDataInheritance{*}{*}{%
  \noinherit{namea}
  \noinherit{nameb}
  \noinherit{sortyear}
  \noinherit{sortname}
  \noinherit{sorttitle}}

\DeclareDataInheritance{mvbook,mvcollection,mvproceedings,mvreference}%
{*}{% ???
  \noinherit{year}
  \noinherit{month}
  \noinherit{day}
  \noinherit{endyear}
  \noinherit{endmonth}
  \noinherit{endday}
  \noinherit{origyear}
  \noinherit{origmonth}
  \noinherit{origday}
  \noinherit{origendyear}
  \noinherit{origendmonth}
  \noinherit{origendday}}

\DeclareSortingScheme{cms}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \name{sortname}
    \name{author}
    \name{namea}
    \name{editor}
    \name{nameb}
    \name{translator}
    \name{namec}
    \field{sorttitle}
    \field{journaltitle}
    \list{organization}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{0000}
  }
}

\newbibmacro*{part+editor+translator}{%
  \ifnameundef{namea}%
  {\ifnameundef{nameb}%
    {}
    {\bibstring{bytranslator}\space%
    \printnames[bytranslator]{nameb}}}%
{\ifnamesequal{namea}{nameb}%
  {\bibstring{byeditortr}\space%
    \printnames[byeditor]{namea}}%
  {\bibstring{byeditor}\space%
    \printnames[byeditor]{namea}%
    \ifnameundef{nameb}%
    {}
    {\newunit
      \bibstring{bytranslator}\space%
      \printnames[bytranslator]{nameb}}}}}

\newbibmacro*{cpart+editor+translator}{%
  \ifnameundef{namea}%
  {\ifnameundef{nameb}%
    {}
    {\bibstring{cbytranslator}\space%
    \printnames[bytranslator]{nameb}}}%
{\ifnamesequal{namea}{nameb}%
  {\bibstring{cbyeditortr}\space%
    \printnames[byeditor]{namea}}%
  {\bibstring{cbyeditor}\space% Need this \space here?
    \printnames[byeditor]{namea}%
    \ifnameundef{nameb}%
    {}
    {\newcunit
      \bibstring{cbytranslator}\space%
      \printnames[bytranslator]{nameb}}}}}

\newbibmacro*{compilestrg}{%
  \ifthenelse{\value{namec}>1\OR\ifandothers{namec}}
  {\bibstring{compilers}}
  {\bibstring{compiler}}
  \clearname{namec}}

\newbibmacro*{transstrg}{%
  \ifthenelse{\value{translator}>1\OR\ifandothers{translator}}
    {\ifnamesequal{translator}{namec}%
      {\bibstring{transcompilers}%
        \clearname{namec}}%
      {\bibstring{translators}}}%
    {\ifnamesequal{translator}{namec}%
      {\bibstring{transcompiler}%
        \clearname{namec}}%
      {\bibstring{translator}}}
    \clearname{translator}}

\newbibmacro*{parttransstrg}{%
  \ifthenelse{\value{nameb}>1\OR\ifandothers{nameb}}
    {\ifnamesequal{nameb}{namec}%
      {\bibstring{transcompilers}%
        \clearname{namec}}%
      {\bibstring{translators}}}%
    {\ifnamesequal{nameb}{namec}%
      {\bibstring{transcompiler}%
        \clearname{namec}}%
      {\bibstring{translator}}}
    \clearname{nameb}}

\newbibmacro*{editstrg}{% Test added for 0.9
  \ifthenelse{\iffieldundef{editortype}\OR
    \iffieldequalstr{editortype}{editor}}
  {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
    {\ifthenelse{\ifnamesequal{editor}{translator}\AND
        \ifnamesequal{editor}{namec}}
      {\bibstring{editortranscompilers}%
        \clearname{translator}%
        \clearname{namec}}%
      {\ifnamesequal{editor}{namec}%
        {\bibstring{editorcompilers}%
          \clearname{namec}}%
        {\ifnamesequal{editor}{translator}%
          {\bibstring{editortranslators}%
            \clearname{translator}}%
          {\bibstring{editors}}}}}%
    {\ifthenelse{\ifnamesequal{editor}{translator}\AND
        \ifnamesequal{editor}{namec}}
      {\bibstring{editortranscompiler}%
        \clearname{translator}%
        \clearname{namec}}%
      {\ifnamesequal{editor}{namec}%
        {\bibstring{editorcompiler}%
          \clearname{namec}}%
        {\ifnamesequal{editor}{translator}%
          {\bibstring{editortranslator}%
            \clearname{translator}}%
          {\bibstring{editor}}}}}}%
  {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
    {\bibstring{\thefield{editortype}s}}
    {\bibstring{\thefield{editortype}}}}
  \clearname{editor}}

\newbibmacro*{parteditstrg}{%
  \ifthenelse{\value{namea}>1\OR\ifandothers{namea}}
    {\ifthenelse{\ifnamesequal{namea}{nameb}\AND
        \ifnamesequal{namea}{namec}}
      {\bibstring{editortranscompilers}%
        \clearname{nameb}%
        \clearname{namec}}%
      {\ifnamesequal{namea}{namec}%
        {\bibstring{editorcompilers}%
          \clearname{namec}}%
        {\ifnamesequal{namea}{nameb}%
          {\bibstring{editortranslators}%
            \clearname{nameb}}%
          {\bibstring{editors}}}}}%
    {\ifthenelse{\ifnamesequal{namea}{nameb}\AND
        \ifnamesequal{namea}{namec}}
      {\bibstring{editortranscompiler}%
        \clearname{nameb}%
        \clearname{namec}}%
      {\ifnamesequal{namea}{namec}%
        {\bibstring{editorcompiler}%
          \clearname{namec}}%
        {\ifnamesequal{namea}{nameb}%
          {\bibstring{editortranslator}%
            \clearname{nameb}}%
          {\bibstring{editor}}}}}%
    \clearname{namea}}

\newbibmacro*{clearorigin}{%
  \toggletrue{cms@origcite}%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
  {\ifnameundef{bookauthor}%
    {\savefield{fullhash}{\bbx@lasthash}%
      \clearname{author}}%
    {\ifnamesequal{author}{bookauthor}%
      {\clearname{bookauthor}%
        \savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}%
      {\savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}}}%
  {\clearname{author}}}%

\newbibmacro*{clearpublin}{%
  \toggletrue{cms@origcite}%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}%
  {\ifnameundef{bookauthor}%
    {\savefield{fullhash}{\bbx@lasthash}%
      \clearname{author}}%
    {\ifnamesequal{author}{bookauthor}%
      {\clearname{bookauthor}%
        \savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}%
      {\savefield{fullhash}{\bbx@lasthash}%
        \clearname{author}}}}%
  {\clearname{author}}%
  \clearname{namea}%
  \clearname{nameb}%
  \clearfield{nameaddon}%
  \ifthenelse{\ifentrytype{periodical}\OR\ifentrytype{mvbook}\OR%
    \ifentrytype{mvcollection}\OR\ifentrytype{mvproceedings}\OR%
    \ifentrytype{mvreference}}%
  {}%
  {\clearfield{title}%
    \clearfield{subtitle}%
    \clearfield{titleaddon}}%
  \clearfield{reprinttitle}%
  \clearfield{usere}%
  \clearlist{language}%
}

\endinput