Reorder server code to isolate FFI implementation.