Cherry-picked 5aba2102b2f62d8a92f262fe6611f9df45088b3a.