cherry-picked 628a571