factor out TLS almost entirely incase its of use to others