Bugfix to TLS tunnel, added debug logging