Fixes for login and logout