Improve logout logic. add some minor changes