cleaned-up version of #11537: unnecessary prefixes removed for gradients

A squashed & rebased version of #11537.