Cherrypicked several changes from v1.70