Backport bugfix from master
Backport bugfix from master