Globals are quite ugly, you probably should rather pass this to the various functions.