Implement recovery and logout

Close #2
Close #7