(Contributed by Yeliang Cang via Daniel Templeton) (cherry picked from commit bb30bd3771442df253cbe55c448379580bd5ad07)