fixed some of the TLS problems