Backport of #8182

Quick’n dirty back port of #8182 - master has a better fix but that should be good enough…