Not sure about the hardware issues (check belts check stepper voltage no too low, not too high) but in regards to the code, I use gCode viewer to step through my code and look for obvious weirdness.
That should help you emanate the code as a error source.
Have you see this post?
Some people are having spindle issues. The random loss in RPM causes the cut to get pulled off course.