Issue #350: Ported commit e8137df from 2.x