Fix bugs with isSameChunk