Fix asynch connection code. Handle errors better.