Made some fixes to problems that caused error. Added logout