fix issue 9579

Remove code bloat and allow any qualifiers
Has to retain property that output has same constness as input