fixed authentication bugs and some other stuff