Various TLS fixes