TLS support added, but not fully tested