Fixed calculation of width,height of cells