removed some global state and some dead code that used it.