Major refactoring of Auth