Changes done to fix issue 7134 to avoid race conditions.

Changes done to fix issue 7134 to avoid race conditions.

I had already signed the CLA.