Fix deadlock in `Disconnect` and other locking improvements