Backport changes from HTTPS branch.