Rafactored and simplified login and logout for avatars.