Cherry pick 11ab6bcd & f34b1b6e