fixed segfault on disconnect