Refactor server architecture