Fixed calculation of inner size