Some more cleanups for connection handling.