Downstream update

Adds code and bugfixes that should have been applied before the
migration branch.