Adding logout and fixing bugs