Refine tls logic for shellInit