prepare for calc_midstate