Fixed several bugs involving disconnecting and stuff.