Factor out handling of new connection to reduce complexity.