Rewrite SSL handling; fix longstanding bug with CloseConnection() which ate CPU