Rebase + squash + fixup of #814.

why both a public and private version of the same thing?