Handle connection errors better