Swapped out the core of state to use concurrent dictionaries

Large changes required, but all for the best. The state object is now
thread safe and given the requirement of a unique key some of the code
can be rewritten to take advantage. It's already shrunk and simplified
some of the code base.