Refactoring code style and password recovery BROKEN