fixed TLS bug, updated logging