Fixed bug in calculation of coefficients.