Last part of reorganization before TLS work starts

Move connection-centric code closer to the object-oriented model