Updated fix for $logout() bug