backported 3787e0afc40993cf0b2360970f4ce61c896063b5 to 1.0