Refactor server structure