Login/logout finally working cleanly and reliably.