Added support for handling disconnections.