Optimize classes Quantities and Dimensionless

Yeah, that was convoluted :tongue: