Refactoring in connection errors treatment.