Refactored SSL I/O session setup code