Scala 2.10

This is a reasonably trivial backport of master to 2.10. I'll self-merge in a moment, but I noticed something I want to do in master first.