Fixing up login/logout code