Re #7672. Refactored according to Michael's comments.
Merge branch 'feature/7672_moment_calc' into develop