Handles connection errors better.