Fixes #4959
Fixes #5236