backport fix from master