Merge pull request #27 from ironjan/master

Fix for #26
Merge pull request #28 from ironjan/master

Mostly refactoring
Fixes #30, Fixes #31
Merge branch 'i30-31'