Slight refactoring of authentication
resolved conflicts