Some auth refactoring