Thanks Simon Charette for the implementation idea. Backport of cc4cb95beff0b75ec169add7e94cc481624a41e6 from main