Fixing some threading problems
Merge pull request #24 from csciuto/master

Fixing some threading problems