Fixed some issues with authentication