Increasing precision of the calculations, implementing some optimization along the way