well, I haven't go through the code, but internal OSC have it's own accuracy, I would compare with a real one first.

Next, how accurate your Frequency measure is? What are you using to measure it? That's pretty low frequency... pretty low frequency will add lots of count if not 100% spot on.

Try on higher frequency and see if the results are better.