Fix some problems with TLS and HTTP