Seems that lots of this code is shared with CoordinatorImpl.handleClusterWrite and ProtobufRequestHandler.HandleRequest. Can we consolidate writing logic in one place to make it less error prune and easier to understand.