Ported regression fixes in 6.8 for #12407 to 7.1 branch

Change-Id: Ie46ab97fc1ff89dd241eec9182ed0f92164b754d