Converted all global varibles to be passed around in a struct