fixed some mehtods dealing with finding previous partition and
calculating offset.