Implement recovery and logout

Close #2 and #7