fixed concurrency/threading issues