Backport of PR #603 to 1.4 branch