thread race condition fixed
style changes according to the hound
Merge pull request #21 from cboursnell/master

thread race condition fixed