More fixes related to the random crash fix.

Change-Id: I667866c1872cdbc224c271bf44a3922bd44c4472