cherry-pick new features from upstream