Concurrency problems addressed.
Cleanup code