diff --git a/src/delegation-list.cpp b/src/delegation-list.cpp
index a0dd7c8..7868943 100644
--- a/src/delegation-list.cpp
+++ b/src/delegation-list.cpp
@@ -42,6 +42,14 @@
 {
 }
 
+DelegationList::DelegationList(std::initializer_list<Delegation> dels)
+  : m_isSorted(true)
+{
+  for (const Delegation& del : dels) {
+    this->insert(del, INS_REPLACE);
+  }
+}
+
 DelegationList::DelegationList(const Block& block, bool wantSort)
 {
   this->wireDecode(block, wantSort);
diff --git a/src/delegation-list.hpp b/src/delegation-list.hpp
index 9f74399..9ef5d97 100644
--- a/src/delegation-list.hpp
+++ b/src/delegation-list.hpp
@@ -23,6 +23,7 @@
 #define NDN_DELEGATION_LIST_HPP
 
 #include "delegation.hpp"
+#include <initializer_list>
 
 namespace ndn {
 
@@ -48,6 +49,13 @@
    */
   DelegationList();
 
+  /** \brief construct a sorted DelegationList with specified delegations
+   *
+   *  This is equivalent to inserting each delegation into an empty DelegationList with INS_REPLACE
+   *  conflict resolution.
+   */
+  DelegationList(std::initializer_list<Delegation> dels);
+
   /** \brief decode a DelegationList
    *  \sa wireDecode
    */
diff --git a/src/link.cpp b/src/link.cpp
index ebdb245..21e6045 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -20,12 +20,6 @@
  */
 
 #include "link.hpp"
-#include "interest.hpp"
-#include "encoding/block-helpers.hpp"
-#include "util/crypto.hpp"
-#include "security/key-chain.hpp"
-
-#include <boost/range/adaptor/reversed.hpp>
 
 namespace ndn {
 
@@ -36,209 +30,125 @@
 static_assert(std::is_base_of<Data::Error, Link::Error>::value,
               "Link::Error should inherit from Data::Error");
 
-Link::Link(const Block& block)
+Link::Link() = default;
+
+Link::Link(const Block& wire, bool wantSort)
 {
-  wireDecode(block);
+  this->wireDecode(wire, wantSort);
 }
 
-Link::Link(const Name& name)
+Link::Link(const Name& name, std::initializer_list<Delegation> dels)
   : Data(name)
+  , m_delList(dels)
 {
+  encodeContent();
 }
 
-Link::Link(const Name& name, std::initializer_list<std::pair<uint32_t, Name>> links)
-  : Data(name)
+void
+Link::encodeContent()
 {
-  m_delegations.insert(links);
+  setContentType(tlv::ContentType_Link);
+
+  if (m_delList.size() > 0) {
+    EncodingEstimator estimator;
+    size_t estimatedSize = m_delList.wireEncode(estimator, tlv::Content);
+
+    EncodingBuffer buffer(estimatedSize, 0);
+    m_delList.wireEncode(buffer, tlv::Content);
+
+    setContent(buffer.block());
+  }
+  else {
+    setContent(nullptr, 0);
+  }
+
+  m_isDelSetDirty = true;
+}
+
+void
+Link::wireDecode(const Block& wire, bool wantSort)
+{
+  Data::wireDecode(wire);
+
+  if (getContentType() != tlv::ContentType_Link) {
+    BOOST_THROW_EXCEPTION(Error("Expected ContentType Link"));
+  }
+
+  m_delList.wireDecode(getContent(), wantSort);
+  m_isDelSetDirty = true;
+}
+
+void
+Link::setDelegationList(const DelegationList& dels)
+{
+  m_delList = dels;
   encodeContent();
 }
 
 void
 Link::addDelegation(uint32_t preference, const Name& name)
 {
-  this->removeDelegationNoEncode(name);
-  m_delegations.insert({preference, name});
+  m_delList.insert(preference, name, DelegationList::INS_REPLACE);
   encodeContent();
 }
 
 bool
 Link::removeDelegation(const Name& name)
 {
-  bool hasRemovedDelegation = this->removeDelegationNoEncode(name);
-  if (hasRemovedDelegation) {
+  size_t nErased = m_delList.erase(name);
+  if (nErased > 0) {
     encodeContent();
   }
-  return hasRemovedDelegation;
+  return nErased > 0;
+}
+
+Link::PairInitializerListHelper::PairInitializerListHelper(std::initializer_list<std::pair<uint32_t, Name>> dels)
+{
+  for (const auto& p : dels) {
+    m_delList.insert(p.first, p.second, DelegationList::INS_REPLACE);
+  }
+}
+
+Link::Link(const Name& name, PairInitializerListHelper dels)
+  : Data(name)
+  , m_delList(std::move(dels.m_delList))
+{
+  encodeContent();
 }
 
 const Link::DelegationSet&
 Link::getDelegations() const
 {
-  return m_delegations;
-}
-
-template<encoding::Tag TAG>
-size_t
-Link::encodeContent(EncodingImpl<TAG>& encoder) const
-{
-  // LinkContent ::= CONTENT-TYPE TLV-LENGTH
-  //                    Delegation+
-
-  // Delegation ::= LINK-DELEGATION-TYPE TLV-LENGTH
-  //              Preference
-  //              Name
-
-  // Preference ::= LINK-PREFERENCE-TYPE TLV-LENGTH
-  //       nonNegativeInteger
-
-  size_t totalLength = 0;
-  for (const auto& delegation : m_delegations |  boost::adaptors::reversed) {
-    size_t delegationLength = 0;
-    delegationLength += std::get<1>(delegation).wireEncode(encoder);
-    delegationLength += prependNonNegativeIntegerBlock(encoder, tlv::LinkPreference,
-                                                       std::get<0>(delegation));
-    delegationLength += encoder.prependVarNumber(delegationLength);
-    delegationLength += encoder.prependVarNumber(tlv::LinkDelegation);
-    totalLength += delegationLength;
+  if (m_isDelSetDirty) {
+    m_delSet.clear();
+    for (const auto& del : m_delList) {
+      m_delSet.emplace(static_cast<uint32_t>(del.preference), del.name);
+    }
+    m_isDelSetDirty = false;
   }
-  totalLength += encoder.prependVarNumber(totalLength);
-  totalLength += encoder.prependVarNumber(tlv::Content);
-  return totalLength;
+  return m_delSet;
 }
 
-template size_t
-Link::encodeContent<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Link::encodeContent<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
-
-void
-Link::encodeContent()
-{
-  onChanged();
-
-  EncodingEstimator estimator;
-  size_t estimatedSize = encodeContent(estimator);
-
-  EncodingBuffer buffer(estimatedSize, 0);
-  encodeContent(buffer);
-
-  setContentType(tlv::ContentType_Link);
-  setContent(buffer.block());
-}
-
-void
-Link::decodeContent()
-{
-  // LinkContent ::= CONTENT-TYPE TLV-LENGTH
-  //                    Delegation+
-
-  // Delegation ::= LINK-DELEGATION-TYPE TLV-LENGTH
-  //              Preference
-  //              Name
-
-  // Preference ::= LINK-PREFERENCE-TYPE TLV-LENGTH
-  //       nonNegativeInteger
-
-  if (getContentType() != tlv::ContentType_Link)
-    {
-      BOOST_THROW_EXCEPTION(Error("Expected Content Type Link"));
-    }
-
-  const Block& content = getContent();
-  content.parse();
-
-  for (auto& delegation : content.elements()) {
-    delegation.parse();
-    Block::element_const_iterator val = delegation.elements_begin();
-    if (val == delegation.elements_end()) {
-      BOOST_THROW_EXCEPTION(Error("Unexpected Link Encoding"));
-    }
-    uint32_t preference;
-    try {
-      preference = static_cast<uint32_t>(readNonNegativeInteger(*val));
-    }
-    catch (const tlv::Error&) {
-      BOOST_THROW_EXCEPTION(Error("Missing Preference field in Link Encoding"));
-    }
-    ++val;
-    if (val == delegation.elements_end()) {
-      BOOST_THROW_EXCEPTION(Error("Missing Name field in Link Encoding"));
-    }
-    Name name(*val);
-    m_delegations.insert({preference, name});
-  }
-}
-
-void
-Link::wireDecode(const Block& wire)
-{
-  Data::wireDecode(wire);
-  decodeContent();
-}
-
-std::tuple<uint32_t, Name>
+Link::DelegationTuple
 Link::getDelegationFromWire(const Block& block, size_t index)
 {
-  block.parse();
-  const Block& contentBlock = block.get(tlv::Content);
-  contentBlock.parse();
-  const Block& delegationBlock = contentBlock.elements().at(index);
-  delegationBlock.parse();
-  if (delegationBlock.type() != tlv::LinkDelegation) {
-    BOOST_THROW_EXCEPTION(Error("Unexpected TLV-TYPE, expecting LinkDelegation"));
-  }
-  return std::make_tuple(
-    static_cast<uint32_t>(
-      readNonNegativeInteger(delegationBlock.get(tlv::LinkPreference))),
-    Name(delegationBlock.get(tlv::Name)));
+  Delegation del = Link(block, false).getDelegationList().at(index);
+  return std::make_tuple(static_cast<uint32_t>(del.preference), del.name);
 }
 
 ssize_t
 Link::findDelegationFromWire(const Block& block, const Name& delegationName)
 {
-  block.parse();
-  const Block& contentBlock = block.get(tlv::Content);
-  contentBlock.parse();
-  size_t counter = 0;
-  for (auto&& delegationBlock : contentBlock.elements()) {
-    delegationBlock.parse();
-    if (delegationBlock.type() != tlv::LinkDelegation) {
-      BOOST_THROW_EXCEPTION(Error("Unexpected TLV-TYPE, expecting LinkDelegation"));
-    }
-    Name name(delegationBlock.get(tlv::Name));
-    if (name == delegationName) {
-      return counter;
-    }
-    ++counter;
-  }
-  return INVALID_SELECTED_DELEGATION_INDEX;
+  DelegationList dels = Link(block, false).getDelegationList();
+  auto i = std::find_if(dels.begin(), dels.end(),
+           [delegationName] (const Delegation& del) { return del.name == delegationName; });
+  return i == dels.end() ? -1 : std::distance(dels.begin(), i);
 }
 
 ssize_t
 Link::countDelegationsFromWire(const Block& block)
 {
-  block.parse();
-  const Block& contentBlock = block.get(tlv::Content);
-  contentBlock.parse();
-  return contentBlock.elements_size();
-}
-
-bool
-Link::removeDelegationNoEncode(const Name& name)
-{
-  bool hasRemoved = false;
-  auto i = m_delegations.begin();
-  while (i != m_delegations.end()) {
-    if (i->second == name) {
-      hasRemoved = true;
-      i = m_delegations.erase(i);
-    }
-    else {
-      ++i;
-    }
-  }
-  return hasRemoved;
+  return Link(block, false).getDelegationList().size();
 }
 
 } // namespace ndn
diff --git a/src/link.hpp b/src/link.hpp
index 03b83a6..3fc4387 100644
--- a/src/link.hpp
+++ b/src/link.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,13 +23,14 @@
 #define NDN_LINK_HPP
 
 #include "data.hpp"
+#include "delegation-list.hpp"
 #include <set>
 
 namespace ndn {
 
 const size_t INVALID_SELECTED_DELEGATION_INDEX = std::numeric_limits<size_t>::max();
 
-/** @brief represents a Link instance
+/** @brief represents a Link object
  */
 class Link : public Data
 {
@@ -44,139 +45,142 @@
     }
   };
 
-  // The ordering is based on the preference number and needs to be preserved
-  typedef std::set<std::pair<uint32_t, Name>> DelegationSet;
-
-  /**
-   * @brief Create an empty Link object
+  /** @brief Create an empty Link object
    *
-   * Note that in certain contexts that use Link::shared_from_this(), Link must be
-   * created using `make_shared`:
+   *  Note that in certain contexts that use Link::shared_from_this(), Link must be
+   *  created using `make_shared`:
    *
-   *     shared_ptr<Link> linkObject = make_shared<Link>();
-   *
-   * Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
+   *      shared_ptr<Link> linkObject = make_shared<Link>();
    */
-  Link() = default;
+  Link();
 
-  /**
-   * @brief Create a Link object from a Block
+  /** @brief Decode a Link object from a Block
+   *  @param wire a TLV block
+   *  @param wantSort if false, relative order among delegations is preserved
    *
-   * Note that in certain contexts that use Link::shared_from_this(), Link must be
-   * created using `make_shared`:
+   *  Note that in certain contexts that use Link::shared_from_this(), Link must be
+   *  created using `make_shared`:
    *
-   *     shared_ptr<Link> linkObject = make_shared<Link>(block);
-   *
-   * Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
+   *      shared_ptr<Link> linkObject = make_shared<Link>(block);
    */
   explicit
-  Link(const Block& block);
+  Link(const Block& wire, bool wantSort = true);
 
-  /**
-   * @brief Create a Link object with the given name
+  /** @brief Create a Link object with the given name and delegations
+   *  @param name A reference to the name of the redirected namespace
+   *  @param dels Delegations in payload
    *
-   * @param name A reference to the name of the redirected namespace
+   *  Note that in certain contexts that use Link::shared_from_this(), Link must be
+   *  created using `make_shared`:
    *
-   * Note that in certain contexts that use Link::shared_from_this(), Link must be
-   * created using `make_shared`:
-   *
-   *     shared_ptr<Link> link = make_shared<Link>(name);
-   *
-   * Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
+   *      shared_ptr<Link> link = make_shared<Link>(name, dels);
    */
   explicit
-  Link(const Name& name);
+  Link(const Name& name, std::initializer_list<Delegation> dels = {});
 
- /**
-   * @brief Create a Link object with the given name and pairs of <Preference, Name>
-   *
-   * @param name A reference to the name of the redirected namespace
-   * @param links A reference to the list of pairs of the redirected namespace
-   * along with its priority
-   *
-   * Note that in certain contexts that use Link::shared_from_this(), Link must be
-   * created using `make_shared`:
-   *
-   *     shared_ptr<Link> link = make_shared<Link>(name, links);
-   *
-   * Otherwise, Link::shared_from_this() will throw std::bad_weak_ptr.
+  /** @brief Decode from the wire format
+   *  @param wire a TLV block
+   *  @param wantSort if false, relative order among delegations is preserved
    */
-  Link(const Name& name, std::initializer_list<std::pair<uint32_t, Name>> links);
+  void
+  wireDecode(const Block& wire, bool wantSort = true);
 
-  /**
-   * @brief Add a delegation in the format of <Name, Preference>
-   * @param preference The preference of the delegation to be added
-   * @param name The name of the delegation to be added
-   * @note If a delegation with @p name exists, its preference will be updated
+  /** @brief Get the delegations
+   */
+  const DelegationList&
+  getDelegationList() const
+  {
+    return m_delList;
+  }
+
+  /** @brief Set the delegations
+   *  @note This is more efficient than multiple addDelegation and removeDelegation invocations.
+   */
+  void
+  setDelegationList(const DelegationList& dels);
+
+  /** @brief Add a delegation in the format of <Name, Preference>
+   *  @param preference The preference of the delegation to be added
+   *  @param name The name of the delegation to be added
+   *  @note If a delegation with @p name exists, its preference will be updated
    */
   void
   addDelegation(uint32_t preference, const Name& name);
 
-  /**
-   * @brief Remove a delegation whose name is @p name
-   * @param name The name of the delegation to be removed
-   * @return true if delegation is removed, otherwise false
+  /** @brief Remove a delegation whose name is @p name
+   *  @param name The name of the delegation to be removed
+   *  @return true if delegation is removed, otherwise false
    */
   bool
   removeDelegation(const Name& name);
 
-  /**
-   * @brief Get the pairs of <Name, Preference>
-   * @return a set of delegations
-   */
-  const DelegationSet&
-  getDelegations() const;
+public: // deprecated APIs
+  using DelegationSet = std::set<std::pair<uint32_t, Name>>;
+  using DelegationTuple = std::tuple<uint32_t, Name>;
 
-  /**
-   * @brief Decode from the wire format
-   * @warning This method does not preserve the relative order between delegations.
-   *     To get a delegation by index, use @p getDelegationFromWire method.
+  class PairInitializerListHelper
+  {
+  public:
+    PairInitializerListHelper(std::initializer_list<std::pair<uint32_t, Name>> dels);
+
+  private:
+    DelegationList m_delList;
+    friend class Link;
+  };
+
+  /** @brief Create a Link object with the given name and delegations
+   *  @param name A reference to the name of the redirected namespace
+   *  @param dels Delegations in payload
+   *  @deprecated use Link(const Name&, std::initializer_list<Delegation>)
+   *  @note This overload is selected only if the caller explicitly passes
+   *        std::initializer_list<std::pair<uint32_t, Name>> to Link constructor;
+   *        otherwise, Link(const Name&, std::initializer_list<Delegation>) is preferred.
    */
-  void
-  wireDecode(const Block& wire);
+  DEPRECATED(
+  Link(const Name& name, PairInitializerListHelper dels));
+
+  /** @deprecated use getDelegationList()
+   */
+  DEPRECATED(
+  const DelegationSet&
+  getDelegations() const);
 
   /** @brief gets the delegation at @p index from @p block
    *  @param block wire format of a Link object
    *  @param index 0-based index of a delegation in the Link object
    *  @return delegation preference and name
    *  @throw std::out_of_range index is out of range
+   *  @deprecated use Link(block, false).getDelegationList().at(index)
    */
-  static std::tuple<uint32_t, Name>
-  getDelegationFromWire(const Block& block, size_t index);
+  DEPRECATED(
+  static DelegationTuple
+  getDelegationFromWire(const Block& block, size_t index));
 
   /** @brief finds index of a delegation with @p delegationName from @p block
    *  @param block wire format of a Link object
    *  @param delegationName delegation name in the Link object
    *  @return 0-based index of the first delegation with @p delegationName ,
    *          or -1 if no such delegation exists
+   *  @deprecated find within Link(block, false).getDelegationList()
    */
+  DEPRECATED(
   static ssize_t
-  findDelegationFromWire(const Block& block, const Name& delegationName);
+  findDelegationFromWire(const Block& block, const Name& delegationName));
 
-  static ssize_t
-  countDelegationsFromWire(const Block& block);
-
-protected:
-  /** @brief prepend Link object as a Content block to the encoder
-   *
-   *  The outermost Content element is not part of Link object structure.
+  /** @deprecated use Link(block, false).getDelegationList().size()
    */
-  template<encoding::Tag TAG>
-  size_t
-  encodeContent(EncodingImpl<TAG>& encoder) const;
+  DEPRECATED(
+  static ssize_t
+  countDelegationsFromWire(const Block& block));
 
+private:
   void
   encodeContent();
 
-  void
-  decodeContent();
-
 private:
-  bool
-  removeDelegationNoEncode(const Name& name);
-
-private:
-  DelegationSet m_delegations;
+  DelegationList m_delList;
+  mutable bool m_isDelSetDirty = false;
+  mutable DelegationSet m_delSet;
 };
 
 } // namespace ndn
