Fix TLS

Closes #18, fixing each of the 3 problems discussed therein.