Added a majority of login code