Merge pull request #24 from csciuto/master

Fixing some threading problems