Fixed a few bugs in login