Fixed some bugs with authentication