Backport fixes for #7318, #8076, #8094, and #7983 to release-0.3