Backport #46 fix from 2.4 to 2.3.5.