Also, not a good idea to just "switch back to g90". How do you know it was in G90 when the script ran? You don't unless you check. May well have been in G91 before the script ran, Gcode is perfect and doing exactly what it should (setting G91 mode) when it should. Then you run the script and that script changes it to G90. How does the Gcode know this changed and how does it overcome this? Well, it doesn't. That is why if you set any modal modes in your script you better check what they were before you set them and set them back to previous status before you finish your script.