Improved RMS calculation.