Forward port of 4afa0e5d2a from stable/3.0.x
4afa0e5d2a
Forward port of 765e6de924 from stable/2.0.x
765e6de924