Fixed bugs in f and mf calculation.