Getting rid of more globals (that I think shouldn't actually be global.)