big refactor, removing global state