properly support logout functionality, close #23