@mahkoh removing global variables make the code easier to reason about even if making it thread safe is not the goal.