Missing fixes after cherry-picking the upstream changes