Reject Count Math issue

I have a machine that has 3 infeed lanes for product at a steady rate. It packages the product into 500 per and stacks on a pallet.
The issue I am having is the reject math is all over the place. It stacks 3 or 4 at a time depending on placement. The outfeed stair steps by 1500 to 2000.
I get negative numbers and I think it might be the way the tags update.

The picture shows the UDT for the machine. Input folder tags point to the OPC tag in a Device folder as these will not be standardized between locations. The Inputs folder tags use a value change tag script to make a non-resetting counter that writes out to the MES tag and to the output tag. The previous is the last shift and the delta is the shift count using the starting tag. This allows me to not hit the database over and over for displays.
The MES Module updates every 60 seconds.
The OPC tags update mostly at a 10 second subscribe.

The question is a rather garbled.

I have a machine that has 3 infeed lanes ...

Why is the number of infeed lanes significant?

... for product at a steady rate.

Why is the rate significant?

It packages the product into 500 per and stacks on a pallet.

Why is the pallet quantity significant?

The issue I am having is the reject math is all over the place. It stacks 3 or 4 at a time depending on placement.

What "stacks 3 or 4 at a time". Again, what is the relevance of this to the maths error?

The outfeed stair steps by 1500 to 2000.

What is "the outfeed stair"?

I get negative numbers and I think it might be the way the tags update.

Where do you get negative numbers? How is the calculation performed? (What is the script?)

The tag structure is rather confusing too. How can Inputs and Outputs both have Infeed Count and Outfeed Count?

Finally, what is the question? (You haven't asked one.) How can we help?

Sorry, I am a squirrel brain most of the time.
Here is the Inputs Script for the tag script.

	if not initialChange and currentValue.quality.isGood() and currentValue.value > 0:
		outputCount = system.tag.getTagValue("[.]../Outputs/Infeed Count")
		if outputCount is None:
			outputCount = 0
		if previousValue.value is None:
			previousValue.value = 0
	
		if currentValue.value > previousValue.value:
			outputCount = outputCount + currentValue.value - previousValue.value
		elif currentValue.value < previousValue.value:
			outputCount = outputCount + currentValue.value
		system.tag.write('[.]../Outputs/Infeed Count', outputCount)

		# Write out to the MES tag			
		# Same level of UDT
		system.tag.write("[.]../../Infeed", outputCount)
		# 1 Level above UDT
#		system.tag.write("[.]../../../Infeed", outputCount)	

This is the Outputs folder tag change script.

	startCount = system.tag.getTagValue("[.]../StartCount/Infeed Count")
	if startCount is None:
		startCount = 0
	deltaCount = currentValue.value - startCount
	system.tag.write("[.]../Delta/Infeed", deltaCount)

Using the Infeed of the machine - the Outfeed shows the trend in the picture.
red is the infeed counter
blue is the outfeed counter.
EDIT - this is not the reject count just the two used to make the infeed count.