Server stuff, added disconnect handling (it was broken).