Cherry-pick Randy's pull request 2354.

@sharadkjaiswal , for you to merge.