Code refactoring

- Refactor client-side code
- Refactor server-side code