moved all globals and initialisation to globals.c