Added global variables that I'd missed previously

ran ok before because variables where already in the environment, now
they are declared in the script itself, so that it runs stand-alone.