properly referenced global variables (for now...)
more global declaration fixes, and fixed validation function declaration