V3.1

Backports of the v4 branch to v3.