Backport upstream changes