Backports for 1.8

backports of gh-4480 and gh-4134