Merge "Fix potential race condition." am: 61fc364601
am: 394faff80c

Change-Id: Id554c6e2ccef8018fa444a4e851bcbb18eeab677