Changed alot of the threading stuff.
The bot can now restart and recover from disconnects without crashing.