network: improved the disconnect and send-message implementations.