This needs to be refactored, perhaps much of it go into  `::MetricFu::Calculate`. It's certainly pretty noisy code in here.