Fixes #1735
Backport #1734