Add variable flags and remove explicit global variables