Fixed authentication refactor