Engine: corrections to AxisScaling class

This adds few safety fixes and also improves scaling results in some uncommon cases.