SQLAlchemy event dispatch.
Refactor thread manager and clean up a little harder.