Removed some global variables, passing objects instead