Changed to handle connect exceptions better