fixed gradient transformation for models with a prefix transformation, better debug output