Fix bugs in bad network state