Copy of pull request #130 instead against the dev branch

This is a copy of #130, only instead being against the dev branch.