[backport] two fixes

Backport two fixes to the 3.0.x branch.