First attempt to fix #97
Fixes #97
Fixes #112
Better #112 solution
Merge pull request #138 from aesedepece/master

Fix for #97 and #112