Merge pull request #38 from Magenic/master

Merging into my fork.
Fixing issue #140 and #135
Merge pull request #141 from jwendl/master

Merging in fixes.