Resolves the issue in #460

Here is the updated pull request against the dev branch.