Updates to login and logout process. Needs testing.