Fixed some bugs around login.