cherrypicked changes from 1.65-archive