Added logout and more debugging output