Use a copy of the metrics object instead of the original.
Fixing global leaks & formatting.