Bubble-merge 971498 979212

Merge bug 971498 and bug 979212 with solving some cherry-pick conflict