Applying #1406 fix to the 2.1.x branch.