Migrate to 3.10 API

This is actually less of a change than it might initially appear.
There's a little cleanup as well.