added logout, and some simplifications