Bugfix/1398

Ported #1398 to 2.4 branch.