fixed errors and added logout support