Refactor to prepare for SNI fixes.