diff --git a/tools/ndn-autoconfig.cpp b/tools/ndn-autoconfig.cpp
index 1fb02b1..3059dc4 100644
--- a/tools/ndn-autoconfig.cpp
+++ b/tools/ndn-autoconfig.cpp
@@ -6,7 +6,6 @@
 
 #include <ndn-cpp-dev/face.hpp>
 #include <ndn-cpp-dev/management/nfd-controller.hpp>
-#include <ndn-cpp-dev/management/nfd-face-management-options.hpp>
 #include <ndn-cpp-dev/security/key-chain.hpp>
 
 #include <sys/types.h>
@@ -18,7 +17,9 @@
 #include <arpa/nameser_compat.h>
 #endif
 
-class NdnAutoconfig : public ndn::nfd::Controller
+namespace tools {
+
+class NdnAutoconfig
 {
 public:
   union QueryAnswer
@@ -26,17 +27,20 @@
     HEADER header;
     uint8_t buf[NS_PACKETSZ];
   };
-  
-  struct Error : public std::runtime_error
+
+  class Error : public std::runtime_error
   {
-    Error(const std::string& what) : std::runtime_error(what)
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
     {
     }
   };
-  
+
   explicit
-  NdnAutoconfig(ndn::Face& face)
-    : ndn::nfd::Controller(face)
+  NdnAutoconfig()
+    : m_controller(m_face)
   {
   }
 
@@ -47,41 +51,42 @@
     ndn::Interest interest(ndn::Name("/localhop/ndn-autoconf/hub"));
     interest.setInterestLifetime(ndn::time::milliseconds(4000)); // 4 seconds
     interest.setMustBeFresh(true);
-    
+
     std::cerr << "Stage 1: Trying muticast discovery..." << std::endl;
     m_face.expressInterest(interest,
                            ndn::bind(&NdnAutoconfig::onDiscoverHubStage1Success, this, _1, _2),
                            ndn::bind(&NdnAutoconfig::discoverHubStage2, this, _1, "Timeout"));
-    
+
     m_face.processEvents();
   }
-  
+
   // First stage OnData Callback
   void
   onDiscoverHubStage1Success(const ndn::Interest& interest, ndn::Data& data)
   {
     const ndn::Block& content = data.getContent();
     content.parse();
-    
+
     // Get Uri
-    ndn::Block::element_const_iterator bockValue = content.find(ndn::tlv::nfd::Uri);
-    if (bockValue == content.elements_end())
+    ndn::Block::element_const_iterator blockValue = content.find(ndn::tlv::nfd::Uri);
+    if (blockValue == content.elements_end())
     {
       discoverHubStage2(interest, "Incorrect reply to stage1");
       return;
     }
-    std::string faceMgmtUri(reinterpret_cast<const char*>(bockValue->value()), bockValue->value_size());
+    std::string faceMgmtUri(reinterpret_cast<const char*>(blockValue->value()),
+                            blockValue->value_size());
     connectToHub(faceMgmtUri);
   }
-  
+
   // First stage OnTimeout callback - start 2nd stage
   void
   discoverHubStage2(const ndn::Interest& interest, const std::string& message)
   {
     std::cerr << message << std::endl;
     std::cerr << "Stage 2: Trying DNS query with default suffix..." << std::endl;
-    
-    _res.retry = 2;   
+
+    _res.retry = 2;
     _res.ndots = 10;
 
     QueryAnswer queryAnswer;
@@ -91,7 +96,7 @@
                                 ns_t_srv,
                                 queryAnswer.buf,
                                 sizeof(queryAnswer));
-    
+
     // 2nd stage failed - move on to the third stage
     if (answerSize < 0)
     {
@@ -107,18 +112,18 @@
       }
     }
   }
-    
+
   // Second stage OnTimeout callback
   void
   discoverHubStage3(const std::string& message)
   {
     std::cerr << message << std::endl;
     std::cerr << "Stage 3: Trying to find home router..." << std::endl;
-  
+
     ndn::KeyChain keyChain;
     ndn::Name identity = keyChain.getDefaultIdentity();
     std::string serverName = "_ndn._udp.";
-    
+
     for (ndn::Name::const_reverse_iterator i = identity.rbegin(); i != identity.rend(); i++)
     {
       serverName.append(i->toEscapedString());
@@ -126,7 +131,7 @@
     }
     serverName += "_homehub._autoconf.named-data.net";
     std::cerr << "Stage3: About to query for a home router: " << serverName << std::endl;
-    
+
     QueryAnswer queryAnswer;
 
     int answerSize = res_query(serverName.c_str(),
@@ -135,7 +140,7 @@
                                queryAnswer.buf,
                                sizeof(queryAnswer));
 
-    
+
     // 3rd stage failed - abort
     if (answerSize < 0)
     {
@@ -151,69 +156,71 @@
         throw Error("Failed to parse DNS response");
       }
     }
-    
+
   }
-  
+
   void
   connectToHub(const std::string& uri)
   {
     std::cerr << "about to connect to: " << uri << std::endl;
-    ndn::nfd::FaceManagementOptions faceOptions;
-    
-    faceOptions.setUri(uri);
-    startFaceCommand("create",
-                     faceOptions,
-                     bind(&NdnAutoconfig::onHubConnectSuccess, this, _1, "Succesfully created face: "),
-                     bind(&NdnAutoconfig::onHubConnectError, this, _1, "Failed to create face: "));
+
+    m_controller.start<ndn::nfd::FaceCreateCommand>(
+       ndn::nfd::ControlParameters()
+         .setUri(uri),
+       bind(&NdnAutoconfig::onHubConnectSuccess, this,
+            _1, "Succesfully created face: "),
+       bind(&NdnAutoconfig::onHubConnectError, this,
+            _1, _2, "Failed to create face: ")
+    );
   }
-  
+
   void
-  onHubConnectSuccess(const ndn::nfd::FaceManagementOptions& resp, const std::string& message)
+  onHubConnectSuccess(const ndn::nfd::ControlParameters& resp, const std::string& message)
   {
     std::cerr << message << resp << std::endl;
   }
-  
+
   void
-  onHubConnectError(const std::string& error, const std::string& message)
+  onHubConnectError(uint32_t code, const std::string& error, const std::string& message)
   {
-    throw Error(message + ": " + error);
+    std::ostringstream os;
+    os << message << ": " << error << " (code: " << code << ")";
+    throw Error(os.str());
   }
 
-  
+
   bool parseHostAndConnectToHub(QueryAnswer& queryAnswer, int answerSize)
   {
     // The references of the next classes are:
     // http://www.diablotin.com/librairie/networking/dnsbind/ch14_02.htm
     // https://gist.github.com/mologie/6027597
-    
-    class rechdr
+
+    struct rechdr
     {
-    public:
       uint16_t type;
       uint16_t iclass;
       uint32_t ttl;
       uint16_t length;
     };
-    
-    class srv_t
+
+    struct srv_t
     {
-    public:
       uint16_t priority;
       uint16_t weight;
       uint16_t port;
       uint8_t* target;
     };
-    
+
     if (ntohs(queryAnswer.header.ancount) == 0)
     {
       std::cerr << "No records found\n" << std::endl;
       return false;
     }
-    
+
     uint8_t* blob = queryAnswer.buf + NS_HFIXEDSZ;
-    
+
     blob += dn_skipname(blob, queryAnswer.buf + answerSize) + NS_QFIXEDSZ;
-    
+
     for (int i = 0; i < ntohs(queryAnswer.header.ancount); i++)
     {
       char hostName[NS_MAXDNAME];
@@ -226,7 +233,7 @@
       {
         return false;
       }
-      
+
       blob += domainNameSize;
 
       domainNameSize = dn_expand(queryAnswer.buf,
@@ -245,28 +252,33 @@
       uri.append(hostName);
       uri.append(":");
       uri.append(boost::lexical_cast<std::string>(convertedPort));
-      
+
       connectToHub(uri);
       return true;
     }
 
     return false;
   }
+
+private:
+  ndn::Face m_face;
+  ndn::nfd::Controller m_controller;
 };
 
+} // namespace tools
 
 int
 main()
 {
-  ndn::Face face;
-  NdnAutoconfig autoConfig(face);
   try
-  {
-    autoConfig.discoverHubStage1();
-  }
+    {
+      tools::NdnAutoconfig autoConfigInstance;
+
+      autoConfigInstance.discoverHubStage1();
+    }
   catch (const std::exception& error)
-  {
-    std::cerr << "ERROR: " << error.what() << std::endl;
-  }
+    {
+      std::cerr << "ERROR: " << error.what() << std::endl;
+    }
   return 0;
 }
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index 9ed5840..ca7d1e6 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -41,9 +41,10 @@
   }
 
   void
-  onNfdCommandFailure(const FaceEventNotification& notification, const std::string& reason)
+  onNfdCommandFailure(const FaceEventNotification& notification,
+                      uint32_t code, const std::string& reason)
   {
-    std::cerr << "FAILED: " << notification << std::endl;
+    std::cerr << "FAILED: " << notification << " (code: " << code << ")" << std::endl;
   }
 
   bool
@@ -91,9 +92,14 @@
          ++prefix)
       {
         std::cout << "Try auto-register: " << *prefix << std::endl;
-        m_controller.fibAddNextHop(*prefix, notification.getFaceId(), m_cost,
-                                   bind(&AutoregServer::onNfdCommandSuccess, this, notification),
-                                   bind(&AutoregServer::onNfdCommandFailure, this, notification, _1));
+
+        m_controller.start<FibAddNextHopCommand>(
+          ControlParameters()
+            .setName(*prefix)
+            .setFaceId(notification.getFaceId())
+            .setCost(m_cost),
+          bind(&AutoregServer::onNfdCommandSuccess, this, notification),
+          bind(&AutoregServer::onNfdCommandFailure, this, notification, _1, _2));
       }
   }
 
diff --git a/tools/nfdc.cpp b/tools/nfdc.cpp
index 285bd9d..fd2fbc3 100644
--- a/tools/nfdc.cpp
+++ b/tools/nfdc.cpp
@@ -13,38 +13,39 @@
 usage(const char* programName)
 {
   std::cout << "Usage:\n" << programName  << " [-h] COMMAND\n"
-  "       -h print usage and exit\n"
-  "\n"
-  "   COMMAND can be one of following:\n"
-  "       add-nexthop <name> <faceId> [<cost>]\n"
-  "           Add a nexthop to a FIB entry\n"
-  "       remove-nexthop <name> <faceId> \n"
-  "           Remove a nexthop from a FIB entry\n"
-  "       create <uri> \n"
-  "           Create a face in one of the following formats:\n"
-  "           UDP unicast:    udp[4|6]://<remote-IP-or-host>[:<remote-port>]\n"
-  "           TCP:            tcp[4|6]://<remote-IP-or-host>[:<remote-port>] \n"
-  "       destroy <faceId> \n"
-  "           Destroy a face\n"
-  "       set-strategy <name> <strategy> \n"
-  "           Set the strategy for a namespace \n"
-  "       unset-strategy <name> \n"
-  "           Unset the strategy for a namespace \n"
-  << std::endl;
+    "       -h print usage and exit\n"
+    "\n"
+    "   COMMAND can be one of following:\n"
+    "       add-nexthop <name> <faceId> [<cost>]\n"
+    "           Add a nexthop to a FIB entry\n"
+    "       remove-nexthop <name> <faceId> \n"
+    "           Remove a nexthop from a FIB entry\n"
+    "       create <uri> \n"
+    "           Create a face in one of the following formats:\n"
+    "           UDP unicast:    udp[4|6]://<remote-IP-or-host>[:<remote-port>]\n"
+    "           TCP:            tcp[4|6]://<remote-IP-or-host>[:<remote-port>] \n"
+    "       destroy <faceId> \n"
+    "           Destroy a face\n"
+    "       set-strategy <name> <strategy> \n"
+    "           Set the strategy for a namespace \n"
+    "       unset-strategy <name> \n"
+    "           Unset the strategy for a namespace \n"
+    << std::endl;
 }
 
 namespace nfdc {
-  
-Controller::Controller(ndn::Face& face)
-  : ndn::nfd::Controller(face)
+
+Nfdc::Nfdc(ndn::Face& face)
+  : m_controller(face)
 {
 }
-  
-Controller::~Controller()
+
+Nfdc::~Nfdc()
 {
 }
+
 bool
-Controller::dispatch(const std::string& command, const char* commandOptions[], int nOptions)
+Nfdc::dispatch(const std::string& command, const char* commandOptions[], int nOptions)
 {
   if (command == "add-nexthop") {
     if (nOptions == 2)
@@ -86,44 +87,48 @@
 }
 
 void
-Controller::fibAddNextHop(const char* commandOptions[], bool hasCost)
+Nfdc::fibAddNextHop(const char* commandOptions[], bool hasCost)
 {
-  ndn::nfd::FibManagementOptions fibOptions;
-  
   const std::string& name = commandOptions[0];
   const int faceId = boost::lexical_cast<int>(commandOptions[1]);
 
-  fibOptions.setName(name);
-  fibOptions.setFaceId(faceId);
+  ControlParameters parameters;
+  parameters
+    .setName(name)
+    .setFaceId(faceId);
 
   if (hasCost)
   {
-    const int cost = boost::lexical_cast<int>(commandOptions[2]);
-    fibOptions.setCost(cost);
+    const uint64_t cost = boost::lexical_cast<uint64_t>(commandOptions[2]);
+    parameters.setCost(cost);
   }
-  startFibCommand("add-nexthop",
-                  fibOptions,
-                  bind(&Controller::onFibSuccess, this, _1, "Nexthop insertion succeeded"),
-                  bind(&Controller::onError, this, _1, "Nexthop insertion failed"));
+
+  m_controller.start<FibAddNextHopCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Nexthop insertion succeeded"),
+    bind(&Nfdc::onError, this, _1, _2, "Nexthop insertion failed"));
 }
 
 void
-Controller::fibRemoveNextHop(const char* commandOptions[])
+Nfdc::fibRemoveNextHop(const char* commandOptions[])
 {
   const std::string& name = commandOptions[0];
   const int faceId = boost::lexical_cast<int>(commandOptions[1]);
-  ndn::nfd::FibManagementOptions fibOptions;
 
-  fibOptions.setName(name);
-  fibOptions.setFaceId(faceId);
-  startFibCommand("remove-nexthop",
-                  fibOptions,
-                  bind(&Controller::onFibSuccess, this, _1, "Nexthop Removal succeeded"),
-                  bind(&Controller::onError, this, _1, "Nexthop Removal failed"));
+  ControlParameters parameters;
+  parameters
+    .setName(name)
+    .setFaceId(faceId);
+
+  m_controller.start<FibRemoveNextHopCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Nexthop removal succeeded"),
+    bind(&Nfdc::onError, this, _1, _2, "Nexthop removal failed"));
 }
 
 namespace {
-bool
+
+inline bool
 isValidUri(const std::string& input)
 {
   // an extended regex to support the validation of uri structure
@@ -131,105 +136,94 @@
   boost::regex e("^[a-z0-9]+\\:.*");
   return boost::regex_match(input, e);
 }
+
 } // anonymous namespace
 
 void
-Controller::faceCreate(const char* commandOptions[])
+Nfdc::faceCreate(const char* commandOptions[])
 {
-  ndn::nfd::FaceManagementOptions faceOptions;
   const std::string& uri = commandOptions[0];
-  faceOptions.setUri(uri);
-  
-  if (isValidUri(uri))
-  {
-    startFaceCommand("create",
-                     faceOptions,
-                     bind(&Controller::onFaceSuccess, this, _1, "Face creation succeeded"),
-                     bind(&Controller::onError, this, _1, "Face creation failed"));
-  }
-  else
+  if (!isValidUri(uri))
     throw Error("invalid uri format");
+
+  ControlParameters parameters;
+  parameters
+    .setUri(uri);
+
+  m_controller.start<FaceCreateCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Face creation succeeded"),
+    bind(&Nfdc::onError, this, _1, _2, "Face creation failed"));
 }
- 
+
 void
-Controller::faceDestroy(const char* commandOptions[])
+Nfdc::faceDestroy(const char* commandOptions[])
 {
-  ndn::nfd::FaceManagementOptions faceOptions;
   const int faceId = boost::lexical_cast<int>(commandOptions[0]);
-  faceOptions.setFaceId(faceId);
-                        
-  startFaceCommand("destroy",
-                   faceOptions,
-                   bind(&Controller::onFaceSuccess, this, _1, "Face destroy succeeded"),
-                   bind(&Controller::onError, this, _1, "Face destroy failed"));
+
+  ControlParameters parameters;
+  parameters
+    .setFaceId(faceId);
+
+  m_controller.start<FaceDestroyCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Face destroy succeeded"),
+    bind(&Nfdc::onError, this, _1, _2, "Face destroy failed"));
 }
-  
+
 void
-Controller::strategyChoiceSet(const char* commandOptions[])
+Nfdc::strategyChoiceSet(const char* commandOptions[])
 {
   const std::string& name = commandOptions[0];
   const std::string& strategy = commandOptions[1];
-  ndn::nfd::StrategyChoiceOptions strategyChoiceOptions;
-  
-  strategyChoiceOptions.setName(name);
-  strategyChoiceOptions.setStrategy(strategy);
-  
-  startStrategyChoiceCommand("set",
-                             strategyChoiceOptions,
-                             bind(&Controller::onSetStrategySuccess,
-                                  this,
-                                  _1,
-                                  "Successfully set strategy choice"),
-                             bind(&Controller::onError, this, _1, "Failed to set strategy choice"));
-  
+
+  ControlParameters parameters;
+  parameters
+    .setName(name)
+    .setStrategy(strategy);
+
+  m_controller.start<StrategyChoiceSetCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Successfully set strategy choice"),
+    bind(&Nfdc::onError, this, _1, _2, "Failed to set strategy choice"));
 }
-  
+
 void
-Controller::strategyChoiceUnset(const char* commandOptions[])
+Nfdc::strategyChoiceUnset(const char* commandOptions[])
 {
   const std::string& name = commandOptions[0];
-  ndn::nfd::StrategyChoiceOptions strategyChoiceOptions;
-  
-  strategyChoiceOptions.setName(name);
-  startStrategyChoiceCommand("unset",
-                             strategyChoiceOptions,
-                             bind(&Controller::onSetStrategySuccess,
-                                  this,
-                                  _1,
-                                  "Successfully unset strategy choice"),
-                             bind(&Controller::onError, this, _1, "Failed to unset strategy choice"));
+
+  ControlParameters parameters;
+  parameters
+    .setName(name);
+
+  m_controller.start<StrategyChoiceUnsetCommand>(
+    parameters,
+    bind(&Nfdc::onSuccess, this, _1, "Successfully unset strategy choice"),
+    bind(&Nfdc::onError, this, _1, _2, "Failed to unset strategy choice"));
 }
-  
+
 void
-Controller::onFibSuccess(const ndn::nfd::FibManagementOptions& resp, const std::string& message)
+Nfdc::onSuccess(const ControlParameters& parameters, const std::string& message)
 {
-  std::cout << message << ": " << resp << std::endl;
+  std::cout << message << ": " << parameters << std::endl;
 }
-  
+
 void
-Controller::onFaceSuccess(const ndn::nfd::FaceManagementOptions& resp, const std::string& message)
+Nfdc::onError(uint32_t code, const std::string& error, const std::string& message)
 {
-  std::cout << message << ": " << resp << std::endl;
+  std::ostringstream os;
+  os << message << ": " << error << " (code: " << code << ")";
+  throw Error(os.str());
 }
-void
-Controller::onSetStrategySuccess(const ndn::nfd::StrategyChoiceOptions& resp,
-                                 const std::string& message)
-{
-  std::cout << message << ": " << resp << std::endl;
-}
-  
-void
-Controller::onError(const std::string& error, const std::string& message)
-{
-  throw Error(message + ": " + error);
-}
+
 } // namespace nfdc
 
 int
 main(int argc, char** argv)
 {
   ndn::Face face;
-  nfdc::Controller p(face);
+  nfdc::Nfdc p(face);
 
   p.m_programName = argv[0];
   int opt;
@@ -238,7 +232,7 @@
       case 'h':
         usage(p.m_programName);
         return 0;
-        
+
       default:
         usage(p.m_programName);
         return 1;
@@ -251,14 +245,14 @@
   }
 
   try {
-    bool hasSucceeded = p.dispatch(argv[optind],
-                                   const_cast<const char**>(argv + optind + 1),
-                                   argc - optind - 1);
-    if (hasSucceeded == false) {
+    bool isOk = p.dispatch(argv[optind],
+                           const_cast<const char**>(argv + optind + 1),
+                           argc - optind - 1);
+    if (!isOk) {
       usage(p.m_programName);
       return 1;
     }
-    
+
     face.processEvents();
   }
   catch (const std::exception& e) {
@@ -267,4 +261,3 @@
   }
   return 0;
 }
-
diff --git a/tools/nfdc.hpp b/tools/nfdc.hpp
index fa131fb..02d5f9a 100644
--- a/tools/nfdc.hpp
+++ b/tools/nfdc.hpp
@@ -10,42 +10,48 @@
 #include <ndn-cpp-dev/face.hpp>
 #include <ndn-cpp-dev/management/controller.hpp>
 #include <ndn-cpp-dev/management/nfd-controller.hpp>
-#include <ndn-cpp-dev/management/nfd-fib-management-options.hpp>
-#include <ndn-cpp-dev/management/nfd-face-management-options.hpp>
-#include <ndn-cpp-dev/management/nfd-strategy-choice-options.hpp>
 #include <vector>
 
 namespace nfdc {
-    
-class Controller : public ndn::nfd::Controller
+
+using namespace ndn::nfd;
+
+class Nfdc
 {
 public:
-  struct Error : public std::runtime_error
+  class Error : public std::runtime_error
   {
-    Error(const std::string& what) : std::runtime_error(what) {}
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
   };
-    
+
   explicit
-  Controller(ndn::Face& face);
-  
-  ~Controller();
-  
+  Nfdc(ndn::Face& face);
+
+  ~Nfdc();
+
   bool
   dispatch(const std::string& cmd,
            const char* cmdOptions[],
            int nOptions);
+
   /**
-   * \brief Adds a nexthop to a FIB entry. 
+   * \brief Adds a nexthop to a FIB entry.
    *
    * If the FIB entry does not exist, it is inserted automatically
    *
    * cmd format:
    *   name
    *
-   * @param cmdOptions           add command without leading 'insert' component
+   * \param cmdOptions Add next hop command parameters without leading 'add-nexthop' component
    */
   void
   fibAddNextHop(const char* cmdOptions[], bool hasCost);
+
   /**
    * \brief Removes a nexthop from an existing FIB entry
    *
@@ -54,10 +60,12 @@
    * cmd format:
    *   name faceId
    *
-   * @param cmdOptions          delNext command without leading 'remove-nexthop' component
+   * \param cmdOptions Remove next hop command parameters without leading
+   *                   'remove-nexthop' component
    */
   void
-  fibRemoveNextHop(const char* cmdOptions[]);  
+  fibRemoveNextHop(const char* cmdOptions[]);
+
   /**
    * \brief create new face
    *
@@ -66,20 +74,22 @@
    * cmd format:
    *   uri
    *
-   * @param cmdOptions          create command without leading 'create' component
+   * \param cmdOptions Create face command parameters without leading 'create' component
    */
   void
   faceCreate(const char* cmdOptions[]);
+
   /**
    * \brief destroy a face
    *
    * cmd format:
    *   faceId
    *
-   * @param cmdOptions          destroy command without leading 'destroy' component
+   * \param cmdOptions Destroy face command parameters without leading 'destroy' component
    */
   void
   faceDestroy(const char* cmdOptions[]);
+
   /**
    * \brief Set the strategy for a namespace
    *
@@ -87,10 +97,12 @@
    * cmd format:
    *   name strategy
    *
-   * @param cmdOptions          Set command without leading 'Unset' component
+   * \param cmdOptions Set strategy choice command parameters without leading
+   *                   'set-strategy' component
    */
   void
   strategyChoiceSet(const char* cmdOptions[]);
+
   /**
    * \brief Unset the strategy for a namespace
    *
@@ -98,31 +110,27 @@
    * cmd format:
    *   name strategy
    *
-   * @param cmdOptions          Unset command without leading 'Unset' component
+   * \param cmdOptions Unset strategy choice command parameters without leading
+   *                   'unset-strategy' component
    */
   void
   strategyChoiceUnset(const char* cmdOptions[]);
-  
+
 private:
   void
-  onFibSuccess(const ndn::nfd::FibManagementOptions& fibOptions,
-               const std::string& message);
+  onSuccess(const ControlParameters& parameters,
+            const std::string& message);
 
   void
-  onFaceSuccess(const ndn::nfd::FaceManagementOptions& faceOptions,
-                const std::string& message);
-  
-  void
-  onSetStrategySuccess(const ndn::nfd::StrategyChoiceOptions& resp,
-                       const std::string& message);
-  void
-  onError(const std::string& error, const std::string& message);
-  
+  onError(uint32_t code, const std::string& error, const std::string& message);
+
 public:
   const char* m_programName;
+
+private:
+  Controller m_controller;
 };
 
 } // namespace nfdc
 
 #endif // NFD_TOOLS_NFDC_HPP
-
