diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 74636d8..2a39e36 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -38,72 +38,51 @@
 
 namespace nfd {
 
-using namespace boost::asio;
+namespace ip = boost::asio::ip;
 
 NFD_LOG_INIT("UdpFactory");
 
-static const boost::asio::ip::address_v4 ALL_V4_ENDPOINT(
-  boost::asio::ip::address_v4::from_string("0.0.0.0"));
-
-static const boost::asio::ip::address_v6 ALL_V6_ENDPOINT(
-  boost::asio::ip::address_v6::from_string("::"));
-
-UdpFactory::UdpFactory(const std::string& defaultPort/* = "6363"*/)
-  : m_defaultPort(defaultPort)
-{
-}
-
 void
 UdpFactory::prohibitEndpoint(const udp::Endpoint& endpoint)
 {
-  using namespace boost::asio::ip;
-
-  const address& address = endpoint.address();
-
-  if (address.is_v4() && address == ALL_V4_ENDPOINT)
-    {
-      prohibitAllIpv4Endpoints(endpoint.port());
-    }
-  else if (endpoint.address().is_v6() && address == ALL_V6_ENDPOINT)
-    {
-      prohibitAllIpv6Endpoints(endpoint.port());
-    }
+  if (endpoint.address().is_v4() &&
+      endpoint.address() == ip::address_v4::any()) {
+    prohibitAllIpv4Endpoints(endpoint.port());
+  }
+  else if (endpoint.address().is_v6() &&
+           endpoint.address() == ip::address_v6::any()) {
+    prohibitAllIpv6Endpoints(endpoint.port());
+  }
 
   NFD_LOG_TRACE("prohibiting UDP " << endpoint);
-
   m_prohibitedEndpoints.insert(endpoint);
 }
 
 void
-UdpFactory::prohibitAllIpv4Endpoints(const uint16_t port)
+UdpFactory::prohibitAllIpv4Endpoints(uint16_t port)
 {
-  using namespace boost::asio::ip;
-
   for (const NetworkInterfaceInfo& nic : listNetworkInterfaces()) {
-    for (const address_v4& addr : nic.ipv4Addresses) {
-      if (addr != ALL_V4_ENDPOINT) {
+    for (const auto& addr : nic.ipv4Addresses) {
+      if (addr != ip::address_v4::any()) {
         prohibitEndpoint(udp::Endpoint(addr, port));
       }
     }
 
-    if (nic.isBroadcastCapable() && nic.broadcastAddress != ALL_V4_ENDPOINT)
-    {
-      NFD_LOG_TRACE("prohibiting broadcast address: " << nic.broadcastAddress.to_string());
+    if (nic.isBroadcastCapable() &&
+        nic.broadcastAddress != ip::address_v4::any()) {
       prohibitEndpoint(udp::Endpoint(nic.broadcastAddress, port));
     }
   }
 
-  prohibitEndpoint(udp::Endpoint(address::from_string("255.255.255.255"), port));
+  prohibitEndpoint(udp::Endpoint(ip::address_v4::broadcast(), port));
 }
 
 void
-UdpFactory::prohibitAllIpv6Endpoints(const uint16_t port)
+UdpFactory::prohibitAllIpv6Endpoints(uint16_t port)
 {
-  using namespace boost::asio::ip;
-
   for (const NetworkInterfaceInfo& nic : listNetworkInterfaces()) {
-    for (const address_v6& addr : nic.ipv6Addresses) {
-      if (addr != ALL_V6_ENDPOINT) {
+    for (const auto& addr : nic.ipv6Addresses) {
+      if (addr != ip::address_v6::any()) {
         prohibitEndpoint(udp::Endpoint(addr, port));
       }
     }
@@ -116,10 +95,15 @@
 {
   NFD_LOG_DEBUG("Creating unicast channel " << endpoint);
 
-  shared_ptr<UdpChannel> channel = findChannel(endpoint);
-  if (static_cast<bool>(channel))
+  auto channel = findChannel(endpoint);
+  if (channel)
     return channel;
 
+  if (endpoint.address().is_multicast()) {
+    BOOST_THROW_EXCEPTION(Error("createChannel is only for unicast channels. The provided endpoint "
+                                "is multicast. Use createMulticastFace to create a multicast face"));
+  }
+
   // check if the endpoint is already used by a multicast face
   auto face = findMulticastFace(endpoint);
   if (face) {
@@ -127,12 +111,6 @@
                                 "endpoint is already allocated for a UDP multicast face"));
   }
 
-  if (endpoint.address().is_multicast()) {
-    BOOST_THROW_EXCEPTION(Error("This method is only for unicast channel. The provided "
-                                "endpoint is multicast. Use createMulticastFace to "
-                                "create a multicast face"));
-  }
-
   channel = make_shared<UdpChannel>(endpoint, timeout);
   m_channels[endpoint] = channel;
   prohibitEndpoint(endpoint);
@@ -141,12 +119,11 @@
 }
 
 shared_ptr<UdpChannel>
-UdpFactory::createChannel(const std::string& localIp,
-                          const std::string& localPort,
+UdpFactory::createChannel(const std::string& localIp, const std::string& localPort,
                           const time::seconds& timeout)
 {
-  using namespace boost::asio::ip;
-  udp::Endpoint endpoint(address::from_string(localIp), boost::lexical_cast<uint16_t>(localPort));
+  udp::Endpoint endpoint(ip::address::from_string(localIp),
+                         boost::lexical_cast<uint16_t>(localPort));
   return createChannel(endpoint, timeout);
 }
 
@@ -167,8 +144,8 @@
   }
 
   // checking if the local endpoint is already in use for a unicast channel
-  shared_ptr<UdpChannel> unicast = findChannel(localEndpoint);
-  if (static_cast<bool>(unicast)) {
+  auto unicastCh = findChannel(localEndpoint);
+  if (unicastCh) {
     BOOST_THROW_EXCEPTION(Error("Cannot create the requested UDP multicast face, local "
                                 "endpoint is already allocated for a UDP unicast channel"));
   }
@@ -203,7 +180,7 @@
   sendSocket.set_option(ip::udp::socket::reuse_address(true));
   sendSocket.set_option(ip::multicast::enable_loopback(false));
   sendSocket.bind(udp::Endpoint(ip::address_v4::any(), multicastEndpoint.port()));
-  if (localEndpoint.address() != ALL_V4_ENDPOINT)
+  if (localEndpoint.address() != ip::address_v4::any())
     sendSocket.set_option(ip::multicast::outbound_interface(localEndpoint.address().to_v4()));
 
   sendSocket.set_option(ip::multicast::join_group(multicastEndpoint.address().to_v4(),
@@ -261,16 +238,16 @@
 UdpFactory::createFace(const FaceUri& uri,
                        ndn::nfd::FacePersistency persistency,
                        const FaceCreatedCallback& onCreated,
-                       const FaceConnectFailedCallback& onConnectFailed)
+                       const FaceCreationFailedCallback& onConnectFailed)
 {
-  if (persistency == ndn::nfd::FacePersistency::FACE_PERSISTENCY_ON_DEMAND) {
-    BOOST_THROW_EXCEPTION(Error("UdpFactory::createFace does not support creating on-demand face"));
-  }
-
   BOOST_ASSERT(uri.isCanonical());
 
-  boost::asio::ip::address ipAddress = boost::asio::ip::address::from_string(uri.getHost());
-  udp::Endpoint endpoint(ipAddress, boost::lexical_cast<uint16_t>(uri.getPort()));
+  if (persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
+    BOOST_THROW_EXCEPTION(Error("UdpFactory::createFace does not support FACE_PERSISTENCY_ON_DEMAND"));
+  }
+
+  udp::Endpoint endpoint(ip::address::from_string(uri.getHost()),
+                         boost::lexical_cast<uint16_t>(uri.getPort()));
 
   if (endpoint.address().is_multicast()) {
     onConnectFailed("The provided address is multicast. Please use createMulticastFace method");
@@ -284,52 +261,47 @@
   }
 
   // very simple logic for now
-  for (ChannelMap::iterator channel = m_channels.begin();
-       channel != m_channels.end();
-       ++channel)
-  {
-    if ((channel->first.address().is_v4() && endpoint.address().is_v4()) ||
-        (channel->first.address().is_v6() && endpoint.address().is_v6()))
-    {
-      channel->second->connect(endpoint, persistency, onCreated, onConnectFailed);
+  for (const auto& i : m_channels) {
+    if ((i.first.address().is_v4() && endpoint.address().is_v4()) ||
+        (i.first.address().is_v6() && endpoint.address().is_v6())) {
+      i.second->connect(endpoint, persistency, onCreated, onConnectFailed);
       return;
     }
   }
 
-  onConnectFailed("No channels available to connect to " +
-                  boost::lexical_cast<std::string>(endpoint));
+  onConnectFailed("No channels available to connect to " + boost::lexical_cast<std::string>(endpoint));
+}
+
+std::vector<shared_ptr<const Channel>>
+UdpFactory::getChannels() const
+{
+  std::vector<shared_ptr<const Channel>> channels;
+  channels.reserve(m_channels.size());
+
+  for (const auto& i : m_channels)
+    channels.push_back(i.second);
+
+  return channels;
 }
 
 shared_ptr<UdpChannel>
-UdpFactory::findChannel(const udp::Endpoint& localEndpoint)
+UdpFactory::findChannel(const udp::Endpoint& localEndpoint) const
 {
-  ChannelMap::iterator i = m_channels.find(localEndpoint);
+  auto i = m_channels.find(localEndpoint);
   if (i != m_channels.end())
     return i->second;
   else
-    return shared_ptr<UdpChannel>();
-}
-
-shared_ptr<face::LpFaceWrapper>
-UdpFactory::findMulticastFace(const udp::Endpoint& localEndpoint)
-{
-  MulticastFaceMap::iterator i = m_multicastFaces.find(localEndpoint);
-  if (i != m_multicastFaces.end())
-    return i->second;
-  else
     return nullptr;
 }
 
-std::list<shared_ptr<const Channel>>
-UdpFactory::getChannels() const
+shared_ptr<face::LpFaceWrapper>
+UdpFactory::findMulticastFace(const udp::Endpoint& localEndpoint) const
 {
-  std::list<shared_ptr<const Channel>> channels;
-  for (ChannelMap::const_iterator i = m_channels.begin(); i != m_channels.end(); ++i)
-    {
-      channels.push_back(i->second);
-    }
-
-  return channels;
+  auto i = m_multicastFaces.find(localEndpoint);
+  if (i != m_multicastFaces.end())
+    return i->second;
+  else
+    return nullptr;
 }
 
 } // namespace nfd
