Fix shadowed variable declaration with misc fixes. Change-Id: I73f61d65297009ffdba7a3c0685a06a5ae559ccb