Fixed problem where TLS exceptions caused an NPE