Merge "Fix possible crash in scale-invariant error calculation" into main