Some cleaning done. Global variables were part of the bugs; now all of the global variables are static