Use a copy of the metrics object instead of the original.
Refactor deepCopy function
Fixing globals leaks
Formatting
Merge pull request #5 from aleasoluciones/fixes

Use a copy of the metrics object instead of the original, fix global leaks and some refactors.