you could have done this in Mach3's ports an pins-> spindle setup. Tick the spindle relay option. then select the OEM Output numbers for M3 and M4. Then go in to the pins and find the output numbers. No need to change the scripts of M3, M4 or M5

This screen will help:

Click image for larger version. 

Name:	Mach3_spindle_setup.jpg 
Views:	301 
Size:	74.5 KB 
ID:	16844