Fix some bugs with the login and logout.