Refactoring for new stateful server implementation