fixed several bugs that were breaking login and logout