Server: Refactoring and implemented Register.