Fixed null pointer bugs in ConnectionHandler