Moved the metrics calculations to its own static class to separate responsibility from the frontend.