Cleaned up metric generation portion