Extract a few methods and cleanup metrics calculator