Cherrypick v1.4.0

This backports #3394 and #3397 to 1.4.x

The content has already been reviewed so this should just be review to confirm that this should be on the 1.4.0 branch and that the cherry-picking is done correctly