Significantly simplify server connection handling, and test.