Forward port of Bill patch.

Patch obtained by doing:

  git diff 3aa5dfe..cms-sw/cms/3aa5dfe | patch -p1

and ignoring the conflict (due to a doublely added header).