Fixed some race conditions.

Submitted by:
Reviewed by:
PR:
16 files changed