incorporates changes from pull request #1510