Various changes

In Grid, fixed the calc_f function