I suggest the extra 74hc14 in the step line might not be the right solution. Perhaps a better one would be to add the inverter into the dir line.
I suspect the error in counting is happening at some direction change transitions (as discovered by another poster)...

But obviously only you can determine if this is true for your board.
The advantage of not doubling up on the step signal is to continue to trigger the step on the rising pulse as per spec sheet.