fixing race condition found by Steven Arzt
Merge branch 'hotfix/fixing-datarace'