Fixed up logout bug and tidied up work