Backport fix #152 to 2.3 branch