Refactors global vars