(Contributed by Chen Liang via Daniel Templeton) (cherry picked from commit 5a75f73893567151f525950cc1a15b3f1bfeac26)