Issues#24#34

Rebased the pull request from #68 onto the current master branch.