additional improvements - precomputing length() and lengthSquared() values