diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp
new file mode 100644
index 0000000..d7a60d7
--- /dev/null
+++ b/daemon/nfd.cpp
@@ -0,0 +1,194 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "nfd.hpp"
+
+#include "core/logger-factory.hpp"
+#include "core/privilege-helper.hpp"
+#include "fw/forwarder.hpp"
+#include "face/null-face.hpp"
+#include "mgmt/internal-face.hpp"
+#include "mgmt/fib-manager.hpp"
+#include "mgmt/face-manager.hpp"
+#include "mgmt/strategy-choice-manager.hpp"
+#include "mgmt/status-server.hpp"
+#include "core/config-file.hpp"
+#include "mgmt/general-config-section.hpp"
+#include "mgmt/tables-config-section.hpp"
+
+namespace nfd {
+
+static const std::string INTERNAL_CONFIG = "internal://nfd.conf";
+
+Nfd::Nfd(const std::string& configFile, ndn::KeyChain& keyChain)
+  : m_configFile(configFile)
+  , m_keyChain(keyChain)
+{
+}
+
+Nfd::Nfd(const ConfigSection& config, ndn::KeyChain& keyChain)
+  : m_configSection(config)
+  , m_keyChain(keyChain)
+{
+}
+
+void
+Nfd::initialize()
+{
+  initializeLogging();
+
+  m_forwarder = make_shared<Forwarder>();
+
+  initializeManagement();
+
+  m_forwarder->getFaceTable().addReserved(make_shared<NullFace>(), FACEID_NULL);
+  m_forwarder->getFaceTable().addReserved(make_shared<NullFace>(FaceUri("contentstore://")),
+                                          FACEID_CONTENT_STORE);
+
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+  PrivilegeHelper::drop();
+#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+}
+
+void
+Nfd::initializeLogging()
+{
+  ConfigFile config(&ConfigFile::ignoreUnknownSection);
+  LoggerFactory::getInstance().setConfigFile(config);
+
+  if (!m_configFile.empty()) {
+    config.parse(m_configFile, true);
+    config.parse(m_configFile, false);
+  }
+  else {
+    config.parse(m_configSection, true, INTERNAL_CONFIG);
+    config.parse(m_configSection, false, INTERNAL_CONFIG);
+  }
+}
+
+
+static inline void
+ignoreRibAndLogSections(const std::string& filename, const std::string& sectionName,
+                        const ConfigSection& section, bool isDryRun)
+{
+  // Ignore "log" and "rib" sections, but raise an error if we're missing a
+  // handler for an NFD section.
+  if (sectionName == "rib" || sectionName == "log") {
+    // do nothing
+  }
+  else {
+    // missing NFD section
+    ConfigFile::throwErrorOnUnknownSection(filename, sectionName, section, isDryRun);
+  }
+}
+
+void
+Nfd::initializeManagement()
+{
+  m_internalFace = make_shared<InternalFace>();
+
+  m_fibManager = make_shared<FibManager>(ref(m_forwarder->getFib()),
+                                         bind(&Forwarder::getFace, m_forwarder.get(), _1),
+                                         m_internalFace,
+                                         ndn::ref(m_keyChain));
+
+  m_faceManager = make_shared<FaceManager>(ref(m_forwarder->getFaceTable()),
+                                           m_internalFace,
+                                           ndn::ref(m_keyChain));
+
+  m_strategyChoiceManager =
+    make_shared<StrategyChoiceManager>(ref(m_forwarder->getStrategyChoice()),
+                                       m_internalFace,
+                                       ndn::ref(m_keyChain));
+
+  m_statusServer = make_shared<StatusServer>(m_internalFace,
+                                             ref(*m_forwarder),
+                                             ndn::ref(m_keyChain));
+
+  ConfigFile config(&ignoreRibAndLogSections);
+  general::setConfigFile(config);
+
+  TablesConfigSection tablesConfig(m_forwarder->getCs(),
+                                   m_forwarder->getPit(),
+                                   m_forwarder->getFib(),
+                                   m_forwarder->getStrategyChoice(),
+                                   m_forwarder->getMeasurements());
+  tablesConfig.setConfigFile(config);
+
+  m_internalFace->getValidator().setConfigFile(config);
+
+  m_forwarder->getFaceTable().addReserved(m_internalFace, FACEID_INTERNAL_FACE);
+
+  m_faceManager->setConfigFile(config);
+
+  // parse config file
+  if (!m_configFile.empty()) {
+    config.parse(m_configFile, true);
+    config.parse(m_configFile, false);
+  }
+  else {
+    config.parse(m_configSection, true, INTERNAL_CONFIG);
+    config.parse(m_configSection, false, INTERNAL_CONFIG);
+  }
+
+  tablesConfig.ensureTablesAreConfigured();
+
+  // add FIB entry for NFD Management Protocol
+  shared_ptr<fib::Entry> entry = m_forwarder->getFib().insert("/localhost/nfd").first;
+  entry->addNextHop(m_internalFace, 0);
+}
+
+void
+Nfd::reloadConfigFile()
+{
+  // Logging
+  initializeLogging();
+  /// \todo Reopen log file
+
+  // Other stuff
+  ConfigFile config(&ignoreRibAndLogSections);
+
+  general::setConfigFile(config);
+
+  TablesConfigSection tablesConfig(m_forwarder->getCs(),
+                                   m_forwarder->getPit(),
+                                   m_forwarder->getFib(),
+                                   m_forwarder->getStrategyChoice(),
+                                   m_forwarder->getMeasurements());
+
+  tablesConfig.setConfigFile(config);
+
+  m_internalFace->getValidator().setConfigFile(config);
+  m_faceManager->setConfigFile(config);
+
+  if (!m_configFile.empty()) {
+    config.parse(m_configFile, false);
+  }
+  else {
+    config.parse(m_configSection, false, INTERNAL_CONFIG);
+  }
+}
+
+} // namespace nfd
