Fixes #3924 (see previous commit 778b543b9bcccaa95ca344f1fdc587033868b691