Added templates for manipulation of quantity types.
+ many fixes.