Huge refactor to authentication process