moved more stuff to state
moved the last globals to state