Some fixes for disconnect