Fix race condition
Merge pull request #295 from MajorBreakfast/patch-1

Fix race condition