Fixed login and logout bugs