Avoided race condition and improved concurrency.

Signed-off-by: Peter Atashian <retep998@gmail.com>