Bug Fixes + improvements.
Major threading + memory fixes.
Merge pull request #86 from mshamash/master

Bug Fixes + improvements.