cherry-picked pull request #788 from STudio26