replaced speedometer driven gear with recommended 40 tooth and still not accurate...

It depends on the toot count. at 40t, a 1 tooth change is 2.5%. It sounds like you need more like 20%. According to these calculations, you would need at least a 45t. Doesn't make sense. Are you sure you don't have a 4:56? Does your speedometer read 31mph at 25gpsmph?