Improved the tracking (avoid code duplication, log average, min and max).