Refactoring the user management (#745)