Fix bugs from #29922

(PR #959)