fixing some bugs with login/logout.