Redo pull #1070 because of conflict with 6_2_X merge

This is a redo of pull request #1070 because of conflicts in merge with 6_2_X.