refactor tls.c

3 jobs for bobdev in 49 minutes and 32 seconds (queued for 7 seconds)