backport of #1092 to stable45

cherry-pick was not possible -> new PR
@icewind1991 @tanghus @bartv2 @butonic please review - THX