Make example script valid
Move globals into an AI struct
Nicer error handling