Merge 1048

This merges PR #1048, which is a prerequisite for merging PR #1075 which is needed for 1.21.  The merge for 1075 will come after this one.