Merge changes from forked repo.

Nasty merge, I'm sorry. Pulled out of some internal stuff that, we realized, would be better handled through the public process.