3.6.x backports

Already reviewed in master.