Backport #746 to the 3.0 line