moves logout to function and fixes some privacy issues