Backport 4512 stable5

Backport #4512 stable5

@dragotin @danimo @icewind1991 @karlitschek THX