Loggin and logout refactors
Fixed login logout issues