Quick and dirty fix... Script now looks for an external display before trying to rotate the screen. If one is present it will automatically deactivate autorotation of the internal screen.
Had some issue that touch is deactivated at start should be fixed...