mitigate non-thread-safe race conditions
further narrowing of the race window
Merge pull request #32 from robocoder/ts-patch

mitigate non-thread-safe race condition