Add global variable checks

Check to see if global variables exist before initializing them.