Cherry-picked pull request 38 from 1.9.x branch to master branch