Move tls initialization to an appropriate callback