heavily refactored and tested Metrics code to enable more metrics to be reported