Fix overflow behavior in next()