Add logout and session purge, tweak behavior