Try modifying the g-code after it is generated so that you know that it is not being modified and see if it works.