Improvements for #33

Contains some improvements to the pull-request #33.
Note that this is a pull request onto the feature branch so it can be accepted without automatically merging to master.