Refactor away RPCHandler::doRpcCommand