Fixes some crash, not disconnect and other minor bug