Fix tracking of token end