Fix unsigned byte overflow error when flag is repeated more than 255 times.