Fix TLS bugs
Resolv merge conflict