Updated the blobal variables to deal with being garbage collected