Wip remove thread mess

This includes commits from #33, please merge that first to make this review manageable.

This requires a fair bit of testing and probably a few eyes. It was written as an 'emergency' patch, which *should* no longer be needed so urgently.

These changes, along with removing complications, should bring a modular data store into feasability. Chances are good this will be my next pull request.

This modular data store should have a more robust lock handling mechanism.