Port the metrics bug fix