Fixed authentication bugs