Backport a few minor chagnes.