Refactoring and logout