Fixes #3044, replaces PR #3046

See #3046.