Fixes #6871. Fixes #6821.

Amended to match the formatting in #6846, to hopefully avoid merge issues.