Native add attributes fix

Mechanical re-factoring to avoid code duplication. Had to introduced a new abstract prototype. Further improvements can be made.