Refactor server files