Update to average calculation for Github Issue #5202

Unused code should be removed not commented out.