[3.6.x] Cherry-pick more relevant changes in master for 3.6.2