some bug fixes in z calib and indexed fitting