tls: fixes and improvements