Changed global variables to sit inside an object.