Pretty significant state refactoring, added new event handling, others

* Overhauled state and made (hopefully) thread safe access from modules
* Added a bunch of new event handlers for things like ban lists and such
* refactored some debug helpers
* minor file cleaning