The change is a cherry-pick of relevant fixes from the following commits on master branch: the followning commits: 9be03c4e980d3058aeb3fd730da5f7d4a4a4f8a8 and e05bb956ce429618fd4f971a9dc708b9313c59ea Change-Id: I87cef323c4eaee4e9f60475f01156b276593fa50