Refactoring authentication.