Better handling fo closed connections.
Improved reconneciton.