Cleam up and moved some connection code.