Is it possible to minimize the number of global variables?