Some fixes in calculation.