Removing some GLOBAL vars and using dependency injection .... not finished yet