Updating to remove global variables

Global variables moved into Query class.