diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
index 27e6b8b..75a3067 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -17,14 +17,23 @@
 package org.onosproject.fpcagent;
 
 import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.felix.scr.annotations.*;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
 import org.onosproject.config.DynamicConfigService;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.fpcagent.helpers.ConfigHelper;
 import org.onosproject.fpcagent.workers.ZMQSBPublisherManager;
 import org.onosproject.fpcagent.workers.ZMQSBSubscriberManager;
-import org.onosproject.net.config.*;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
 import org.onosproject.net.config.basics.SubjectFactories;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.IetfDmmFpcagentService;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ErrorTypeId;
@@ -38,7 +47,13 @@
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.result.ResultEnum;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultErr;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbodydpn.resulttype.DefaultEmptyCase;
-import org.onosproject.yang.model.*;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.RpcInput;
+import org.onosproject.yang.model.RpcOutput;
+import org.onosproject.yang.model.RpcRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -118,6 +133,9 @@
         log.info("FPC Agent Stopped");
     }
 
+    /**
+     * Initialize ZMQ Managers based on configuration.
+     */
     private void init() {
         fpcConfig.getConfig().ifPresent(
                 helper -> {
@@ -153,7 +171,7 @@
         output.resultType(new DefaultEmptyCase());
 
         try {
-            tenantService.getModelObjects(rpcInput.data(), configureDpnResourceId).forEach(
+            tenantService.getModelObjects(rpcInput.data(), configureDpn).forEach(
                     modelObject -> {
                         DefaultConfigureDpnInput input = (DefaultConfigureDpnInput) modelObject;
                         String dpnId = input.inputDpnId().fpcIdentity().union().string();
@@ -183,7 +201,7 @@
         DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
 
         try {
-            for (ModelObject modelObject : tenantService.getModelObjects(rpcInput.data(), configureResourceId)) {
+            for (ModelObject modelObject : tenantService.getModelObjects(rpcInput.data(), configure)) {
                 DefaultConfigureInput input = (DefaultConfigureInput) modelObject;
                 switch (input.opType()) {
                     case CREATE:
@@ -212,11 +230,10 @@
                 }
                 configureOutput.opId(input.opId());
             }
-            // TODO fix DELETE to update the NODE correctly.
-            tenantService.getTenants().ifPresent(tenants -> tenantService.updateNode(tenants));
         } catch (Exception e) {
+            // if there is an exception respond with an error.
             DefaultErr defaultErr = new DefaultErr();
-            defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+            defaultErr.errorInfo(ExceptionUtils.getMessage(e));
             defaultErr.errorTypeId(ErrorTypeId.of(0));
             configureOutput.resultType(defaultErr);
             configureOutput.result(Result.of(ResultEnum.ERR));
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
index 6f1ebf1..f0fed23 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
@@ -17,37 +17,31 @@
 package org.onosproject.fpcagent;
 
 import com.google.common.collect.Maps;
-import org.onosproject.restconf.utils.RestconfUtils;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.TenantKeys;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DefaultDownlinkDataNotification;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DownlinkDataNotification;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnId;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpcidentity.FpcIdentityUnion;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultResourceData;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.AbstractMap;
 import java.util.Arrays;
 import java.util.Map;
 
-import static org.onosproject.fpcagent.helpers.Converter.fromIntToLong;
-import static org.onosproject.fpcagent.helpers.Converter.toBigInt;
+import static org.onosproject.fpcagent.helpers.Converter.*;
 
 /**
  * Helper class which stores all the static variables.
  */
 public class FpcUtil {
-    protected static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
-
     public static final int MAX_EVENTS = 1000;
     public static final int MAX_BATCH_MS = 5000;
     public static final int MAX_IDLE_MS = 1000;
@@ -55,9 +49,23 @@
     public static final String UNKNOWN_EVENT = "FPC Agent listener: unknown event: {}";
     public static final String EVENT_NULL = "Event cannot be null";
     public static final String FPC_APP_ID = "org.onosproject.fpcagent";
-
+    protected static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
     private static final Map<String, FpcDpnId> uplinkDpnMap = Maps.newConcurrentMap();
     private static final Map<String, Short> nodeToTopicMap = Maps.newConcurrentMap();
+    public static ModelConverter modelConverter = null;
+    // Resource ID for Configure DPN RPC command
+    public static ResourceId configureDpn;
+    // Resource ID for Configure RPC command
+    public static ResourceId configure;
+    // Resource ID for tenants data
+    public static ResourceId tenants;
+    public static ResourceId defaultTenant;
+    public static ResourceId defaultTenantMobility;
+    public static ResourceId module;
+    public static ResourceId registerClientResourceId;
+    public static ResourceId deregisterClientResourceId;
+
+    public static FpcIdentity defaultIdentity = getFpcIdentity.apply("default");
 
     private static byte DPN_HELLO = 0b0000_0001;
     private static byte DPN_BYE = 0b0000_0010;
@@ -67,34 +75,77 @@
     private static byte DPN_REPLY = 0b0000_0100;
     private static String DOWNLINK_DATA_NOTIFICATION_STRING = "Downlink-Data-Notification";
 
-    // Resource ID for Configure DPN RPC command
-    public static ResourceId configureDpnResourceId;
-    // Resource ID for Configure RPC command
-    public static ResourceId configureResourceId;
-    // Resource ID for tenants data
-    public static ResourceId tenantsResourceId;
-    public static ResourceId registerClientResourceId;
-    public static ResourceId deregisterClientResourceId;
+    /**
+     * Returns resource id from model converter.
+     *
+     * @param modelId model object id
+     * @return resource id
+     */
+    static ResourceId getResourceVal(ModelObjectId modelId) {
+        DefaultModelObjectData.Builder data = DefaultModelObjectData.builder()
+                .identifier(modelId);
+        ResourceData resData = modelConverter.createDataNode(data.build());
+        return resData.resourceId();
+    }
 
-    static {
-        try {
-            configureDpnResourceId = RestconfUtils.convertUriToRid(
-                    new URI("/onos/restconf/operations/ietf-dmm-fpcagent:configure-dpn")
-            );
-            configureResourceId = RestconfUtils.convertUriToRid(
-                    new URI("/onos/restconf/operations/ietf-dmm-fpcagent:configure")
-            );
-            tenantsResourceId = RestconfUtils.convertUriToRid(
-                    new URI("/onos/restconf/data/ietf-dmm-fpcagent:tenants")
-            );
-            registerClientResourceId = RestconfUtils.convertUriToRid(
-                    new URI("/onos/restconf/data/fpc:register-client")
-            );
-            deregisterClientResourceId = RestconfUtils.convertUriToRid(
-                    new URI("/onos/restconf/data/fpc:deregister-client")
-            );
-        } catch (URISyntaxException ignored) {
-        }
+    /**
+     * Returns the resource id, after constructing model object id and
+     * converting it.
+     */
+    static void getResourceId() {
+        ModelObjectId moduleId = ModelObjectId.builder().build();
+        module = getResourceVal(moduleId);
+
+        ModelObjectId tenantsId = ModelObjectId.builder()
+                .addChild(DefaultTenants.class)
+                .build();
+
+        tenants = getResourceVal(tenantsId);
+
+        TenantKeys tenantKeys = new TenantKeys();
+        tenantKeys.tenantId(defaultIdentity);
+
+        ModelObjectId defaultTenantId = ModelObjectId.builder()
+                .addChild(DefaultTenants.class)
+                .addChild(DefaultTenant.class, tenantKeys)
+                .build();
+
+        defaultTenant = getResourceVal(defaultTenantId);
+
+        configure = ResourceId.builder()
+                .addBranchPointSchema("/", null)
+                .addBranchPointSchema("configure", "urn:ietf:params:xml:ns:yang:fpcagent")
+                .build();
+
+        configureDpn = ResourceId.builder()
+                .addBranchPointSchema("/", null)
+                .addBranchPointSchema("configure-dpn", "urn:ietf:params:xml:ns:yang:fpcagent")
+                .build();
+    }
+
+    static ModelObjectId.Builder defaultTenantBuilder() {
+        TenantKeys tenantKeys = new TenantKeys();
+        tenantKeys.tenantId(defaultIdentity);
+
+        return ModelObjectId.builder()
+                .addChild(DefaultTenants.class)
+                .addChild(DefaultTenant.class, tenantKeys);
+    }
+
+    /**
+     * Returns resource id for the specific tenant ID.
+     *
+     * @param tenantId tenant id
+     * @return resource ids
+     */
+    static ResourceId getTenantResourceId(FpcIdentity tenantId) {
+        TenantKeys tenantKeys = new TenantKeys();
+        tenantKeys.tenantId(tenantId);
+
+        return getResourceVal(ModelObjectId.builder()
+                .addChild(DefaultTenants.class)
+                .addChild(DefaultTenant.class, tenantKeys)
+                .build());
     }
 
     /**
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
index dcadbc1..0fa75c2 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.onosproject.fpcagent;
 
 import com.google.common.collect.Maps;
@@ -14,7 +30,6 @@
 import org.onosproject.config.Filter;
 import org.onosproject.fpcagent.helpers.DpnCommunicationService;
 import org.onosproject.fpcagent.helpers.DpnNgicCommunicator;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.IetfDmmFpcagentOpParam;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.*;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.instructions.instructions.instrtype.Instr3GppMob;
@@ -26,10 +41,11 @@
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultDeleteSuccess;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultErr;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.Tenant;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcMobility;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcPolicy;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcTopology;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.ContextsKeys;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dpns;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.mobilityinfo.mobprofileparameters.ThreegppTunnel;
@@ -48,16 +64,13 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.onosproject.fpcagent.FpcUtil.*;
 import static org.onosproject.fpcagent.helpers.Converter.convertContext;
-import static org.onosproject.fpcagent.helpers.Converter.getFpcIdentity;
 
 @Component(immediate = true)
 @Service
 public class TenantManager implements TenantService {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private final IetfDmmFpcagentOpParam fpcAgentData = new IetfDmmFpcagentOpParam();
-
-    private final Map<ClientIdentifier, Tenant> clientIdMap = Maps.newHashMap();
+    private final Map<ClientIdentifier, DefaultTenant> clientIdMap = Maps.newHashMap();
 
     private final InternalConfigListener listener = new InternalConfigListener();
 
@@ -73,31 +86,29 @@
 
     @Activate
     protected void activate() {
+        FpcUtil.modelConverter = modelConverter;
+        getResourceId();
+
         dpnCommunicationService = new DpnNgicCommunicator();
 
         dynamicConfigService.addListener(listener);
 
-        // Create the Default Tenant on activate
+        // Create the Default Tenant and added to the Tenants structure.
         DefaultTenants tenants = new DefaultTenants();
-
         DefaultTenant tenant = new DefaultTenant();
-        tenant.tenantId(getFpcIdentity.apply("default"));
-
+        tenant.tenantId(defaultIdentity);
         tenant.fpcTopology(new DefaultFpcTopology());
-
         tenant.fpcPolicy(new DefaultFpcPolicy());
-
         tenant.fpcMobility(new DefaultFpcMobility());
-
         tenants.addToTenant(tenant);
 
+        // Initialize FPC™2 Agent Information.
         DefaultFpcAgentInfo fpcAgentInfo = new DefaultFpcAgentInfo();
 
-        fpcAgentData.tenants(tenants);
-        fpcAgentData.fpcAgentInfo(fpcAgentInfo);
-
-        createNode(tenants);
-        createNode(fpcAgentInfo);
+        // Create nodes in dynamic configuration store for RESTCONF accessibility.
+        final ModelObjectId root = ModelObjectId.builder().build();
+        createNode(tenants, root);
+        createNode(fpcAgentInfo, root);
 
         log.info("Tenant Service Started");
     }
@@ -109,60 +120,73 @@
     }
 
     @Override
-    public Optional<Tenant> getDefaultTenant() {
-        return fpcAgentData.tenants().tenant().stream()
-                .filter(tenant -> tenant.tenantId().equals(getFpcIdentity.apply("default")))
+    public Optional<DefaultTenant> getDefaultTenant() {
+        Filter filter = Filter.builder().build();
+        DataNode dataNode = dynamicConfigService.readNode(defaultTenant, filter);
+
+        return getModelObjects(dataNode, tenants)
+                .stream()
+                .map(modelObject -> (DefaultTenant) modelObject)
                 .findFirst();
     }
 
     @Override
     public Optional<DefaultTenants> getTenants() {
-        if (fpcAgentData.tenants() instanceof DefaultTenants) {
-            return Optional.ofNullable((DefaultTenants) fpcAgentData.tenants());
-        }
-        return Optional.empty();
-    }
+        Filter filter = Filter.builder().build();
+        DataNode dataNode = dynamicConfigService.readNode(tenants, filter);
 
-    public Optional<Tenant> getTenant(FpcIdentity tenantId) {
-        return fpcAgentData.tenants().tenant().stream()
-                .filter(tenant -> tenant.tenantId().equals(tenantId))
+        return getModelObjects(dataNode, null)
+                .stream()
+                .map(modelObject -> (DefaultTenants) modelObject)
                 .findFirst();
     }
 
-    public Optional<Tenant> getTenant(ClientIdentifier clientId) {
+    @Override
+    public Optional<DefaultTenant> getTenant(FpcIdentity tenantId) {
+        Filter filter = Filter.builder().build();
+        DataNode dataNode = dynamicConfigService.readNode(getTenantResourceId(tenantId), filter);
+
+        return getModelObjects(dataNode, tenants)
+                .stream()
+                .map(modelObject -> (DefaultTenants) modelObject)
+                .findFirst()
+                .flatMap(defaultTenants ->
+                        defaultTenants.tenant()
+                                .stream()
+                                .filter(defaultTenant ->
+                                        defaultTenant.tenantId().equals(tenantId))
+                                .findFirst()
+                                .map(defaultTenant -> (DefaultTenant) defaultTenant)
+                );
+    }
+
+    @Override
+    public Optional<DefaultTenant> getTenant(ClientIdentifier clientId) {
         return Optional.ofNullable(clientIdMap.get(clientId));
     }
 
-    public Optional<Tenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId) {
+    @Override
+    public Optional<DefaultTenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId) {
         return getTenant(tenantId).map(tenant -> clientIdMap.put(clientId, tenant));
     }
 
-    public Optional<Tenant> deregisterClient(ClientIdentifier clientId) {
+    @Override
+    public Optional<DefaultTenant> deregisterClient(ClientIdentifier clientId) {
         return Optional.ofNullable(clientIdMap.remove(clientId));
     }
 
-    private ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
-        if (resId != null) {
-            return DefaultResourceData.builder()
-                    .addDataNode(dataNode)
-                    .resourceId(resId)
-                    .build();
-        } else {
-            return DefaultResourceData.builder()
-                    .addDataNode(dataNode)
-                    .build();
-        }
-    }
-
+    @Override
     public List<ModelObject> getModelObjects(DataNode dataNode, ResourceId resourceId) {
         ResourceData data = getResourceData(dataNode, resourceId);
         ModelObjectData modelData = modelConverter.createModel(data);
         return modelData.modelObjects();
     }
 
-    public void createNode(InnerModelObject innerModelObject) {
+    @Override
+    public void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
         ResourceData dataNode = modelConverter.createDataNode(
                 DefaultModelObjectData.builder()
+                        .identifier(modelObjectId)
                         .addModelObject(innerModelObject)
                         .build()
         );
@@ -171,9 +195,11 @@
         );
     }
 
-    public void updateNode(InnerModelObject innerModelObject) {
+    @Override
+    public void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
         ResourceData dataNode = modelConverter.createDataNode(
                 DefaultModelObjectData.builder()
+                        .identifier(modelObjectId)
                         .addModelObject(innerModelObject)
                         .build()
         );
@@ -182,6 +208,7 @@
         );
     }
 
+    @Override
     public DefaultConfigureOutput configureCreate(
             CreateOrUpdate create,
             ClientIdentifier clientId,
@@ -189,60 +216,67 @@
     ) {
         DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
         Collection<Callable<Object>> tasks = new ArrayList<>();
-        DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
         try {
+            DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
             for (Contexts context : create.contexts()) {
+                // add context to response.
                 defaultCommonSuccess.addToContexts(context);
 
+                // check if mobility exists and if the context id exists.
                 if (getDefaultTenant().map(
                         tenant -> tenant.fpcMobility().contexts() != null && tenant.fpcMobility()
                                 .contexts()
                                 .stream()
                                 .anyMatch(contexts -> contexts.contextId().equals(context.contextId()))
                 ).orElse(false)) {
-                    throw new IllegalStateException("Context already exists.");
+                    // throw exception if trying to create a Context that already exists.
+                    throw new IllegalStateException("Context tried to create already exists. Please issue update operation..");
                 }
 
                 for (Dpns dpn : context.dpns()) {
+                    // check if dpns exists and if there is a DPN registered for the wanted identifier.
                     if (getDefaultTenant().map(
                             tenant -> tenant.fpcTopology().dpns() == null ||
                                     tenant.fpcTopology().dpns().stream()
                                             .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
                     ).orElse(false)) {
+                        // throw exception if DPN ID is not registered.
                         throw new IllegalStateException("DPN ID is not registered to the topology.");
                     }
 
+                    // handle only 3GPP instructions.
                     if (context.instructions().instrType() instanceof Instr3GppMob) {
-                        Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
-                        String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
-
-                        Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
-                                s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString()),
-                                sgi_enodeb_ipv4 = Ip4Address.valueOf(context.dl().tunnelRemoteAddress().toString()),
-                                sgi_sgw_ipv4 = Ip4Address.valueOf(context.dl().tunnelLocalAddress().toString());
-
-                        long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
-                                client_id = clientId.fpcIdentity().union().int64(),
-                                session_id = context.contextId().fpcIdentity().union().int64();
-
-                        BigInteger op_id = operationId.uint64(),
-                                imsi = context.imsi().uint64();
-
-                        short default_ebi = context.ebi().uint8(),
-                                lbi = context.lbi().uint8();
-
+                        // from DPN ID find the Network and Node Identifiers
                         Optional<String> key = getDefaultTenant().flatMap(tenant ->
                                 tenant.fpcTopology()
                                         .dpns()
                                         .stream()
                                         .filter(dpns -> dpns.dpnId().equals(dpn.dpnId()))
-                                        .findFirst().map(node -> node.nodeId() + "/" + node.networkId())
+                                        .findFirst()
+                                        .map(node -> node.nodeId() + "/" + node.networkId())
                         );
 
                         if (key.isPresent()) {
-                            Short topic_id = FpcUtil.getTopicFromNode(key.get());
+                            // get DPN Topic from Node/Network pair
+                            Short topic_id = getTopicFromNode(key.get());
 
                             if (topic_id != null) {
+                                Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+                                String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+
+                                Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+                                        s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+
+                                long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
+                                        client_id = clientId.fpcIdentity().union().int64(),
+                                        session_id = context.contextId().fpcIdentity().union().int64();
+
+                                BigInteger op_id = operationId.uint64(),
+                                        imsi = context.imsi().uint64();
+
+                                short default_ebi = context.ebi().uint8();
+
+                                // parse tunnel identifiers. throw exception if mobility profile parameters are missing.
                                 if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
                                     s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
                                 } else {
@@ -254,7 +288,7 @@
                                     throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
                                 }
 
-
+                                // TODO try to make sense out of this...
                                 if (commands.contains("session")) {
                                     tasks.add(Executors.callable(() -> {
                                         dpnCommunicationService.create_session(
@@ -269,9 +303,10 @@
                                                 op_id
                                         );
 
-                                        getDefaultTenant().ifPresent(
-                                                tenant -> tenant.fpcMobility().addToContexts(convertContext(context))
-                                        );
+                                        ModelObjectId modelObjectId = defaultTenantBuilder()
+                                                .addChild(DefaultFpcMobility.class)
+                                                .build();
+                                        createNode(convertContext(context), modelObjectId);
                                     }));
 
                                     if (commands.contains("downlink")) {
@@ -286,9 +321,10 @@
                                                     op_id
                                             );
 
-                                            getDefaultTenant().ifPresent(
-                                                    tenant -> tenant.fpcMobility().addToContexts(convertContext(context))
-                                            );
+                                            ModelObjectId modelObjectId = defaultTenantBuilder()
+                                                    .addChild(DefaultFpcMobility.class)
+                                                    .build();
+                                            createNode(convertContext(context), modelObjectId);
                                         }));
                                     }
                                 } else if (commands.contains("indirect-forward")) {
@@ -310,21 +346,25 @@
 //                                    }));
                                 }
                             } else {
-                                throw new IllegalArgumentException("Could not find Topic ID");
+                                throw new IllegalArgumentException("Could not find Topic ID.");
                             }
                         } else {
                             throw new IllegalArgumentException("DPN does not have node and network ID defined.");
                         }
+                    } else {
+                        throw new IllegalArgumentException("No 3GPP instructions where given.");
                     }
                 }
             }
 
+            // execute all tasks.
             ExecutorService executor = Executors.newWorkStealingPool();
             executor.invokeAll(tasks).forEach(
                     future -> {
                         try {
                             future.get();
                         } catch (Exception e) {
+                            log.error(ExceptionUtils.getFullStackTrace(e));
                             throw new IllegalStateException(e);
                         }
                     }
@@ -333,16 +373,18 @@
             configureOutput.resultType(defaultCommonSuccess);
             configureOutput.result(Result.of(ResultEnum.OK));
         } catch (Exception e) {
+            // if there is an exception respond with an error.
             log.error(ExceptionUtils.getFullStackTrace(e));
             DefaultErr defaultErr = new DefaultErr();
             configureOutput.resultType(defaultErr);
-            defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+            defaultErr.errorInfo(ExceptionUtils.getMessage(e));
             defaultErr.errorTypeId(ErrorTypeId.of(0));
         }
 
         return configureOutput;
     }
 
+    @Override
     public DefaultConfigureOutput configureUpdate(
             CreateOrUpdate update,
             ClientIdentifier clientId,
@@ -350,12 +392,13 @@
     ) {
         DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
         Collection<Callable<Object>> tasks = new ArrayList<>();
-
         try {
             DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
             for (Contexts context : update.contexts()) {
+                // add updated context to response.
                 defaultCommonSuccess.addToContexts(context);
 
+                // check if contexts are populated and if they include the wanted context to update.
                 if (getDefaultTenant().map(
                         tenant -> tenant.fpcMobility().contexts() == null ||
                                 tenant.fpcMobility()
@@ -363,34 +406,25 @@
                                         .parallelStream()
                                         .noneMatch(contexts -> contexts.contextId().equals(context.contextId()))
                 ).orElse(false)) {
-                    throw new IllegalStateException("Context doesn't exist.");
+                    // throw exception if wanted context does not exist.
+                    throw new IllegalStateException("Context doesn't exist. Please issue create operation..");
                 }
 
                 for (Dpns dpn : context.dpns()) {
+                    // check if dpns exists and if there is a DPN registered for the wanted identifier.
                     if (getDefaultTenant().map(
                             tenant -> tenant.fpcTopology().dpns() == null ||
                                     tenant.fpcTopology().dpns()
                                             .stream()
                                             .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
                     ).orElse(false)) {
+                        // throw exception if DPN ID is not registered.
                         throw new IllegalStateException("DPN ID is not registered to the topology.");
                     }
 
+                    // handle only 3GPP instructions.
                     if (context.instructions().instrType() instanceof Instr3GppMob) {
-                        Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
-                        String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
-
-                        Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
-                                s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString()),
-                                sgi_enodeb_ipv4 = Ip4Address.valueOf(context.dl().tunnelRemoteAddress().toString()),
-                                sgi_sgw_ipv4 = Ip4Address.valueOf(context.dl().tunnelLocalAddress().toString());
-
-                        long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
-                                cId = clientId.fpcIdentity().union().int64(),
-                                contextId = context.contextId().fpcIdentity().union().int64();
-
-                        BigInteger opId = operationId.uint64();
-
+                        // from DPN ID find the Network and Node Identifiers
                         Optional<String> key = getDefaultTenant().flatMap(tenant ->
                                 tenant.fpcTopology()
                                         .dpns()
@@ -400,14 +434,22 @@
                         );
 
                         if (key.isPresent()) {
-                            Short topic_id = FpcUtil.getTopicFromNode(key.get());
+                            // get DPN Topic from Node/Network pair
+                            Short topic_id = getTopicFromNode(key.get());
 
                             if (topic_id != null) {
-                                if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
-                                    s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
-                                } else {
-                                    throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
-                                }
+                                Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+                                String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+
+                                Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+                                        s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+
+                                long s1u_enb_gtpu_teid,
+                                        cId = clientId.fpcIdentity().union().int64(),
+                                        contextId = context.contextId().fpcIdentity().union().int64();
+
+                                BigInteger opId = operationId.uint64();
+
                                 if (context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
                                     s1u_enb_gtpu_teid = ((ThreegppTunnel) context.dl().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
                                 } else {
@@ -416,17 +458,22 @@
 
                                 if (commands.contains("downlink")) {
                                     if (context.dl().lifetime() >= 0L) {
-                                        tasks.add(Executors.callable(() ->
-                                                dpnCommunicationService.modify_bearer(
-                                                        topic_id,
-                                                        s1u_sgw_ipv4,
-                                                        s1u_enb_gtpu_teid,
-                                                        s1u_enodeb_ipv4,
-                                                        contextId,
-                                                        cId,
-                                                        opId
-                                                )
-                                        ));
+                                        tasks.add(Executors.callable(() -> {
+                                            dpnCommunicationService.modify_bearer(
+                                                    topic_id,
+                                                    s1u_sgw_ipv4,
+                                                    s1u_enb_gtpu_teid,
+                                                    s1u_enodeb_ipv4,
+                                                    contextId,
+                                                    cId,
+                                                    opId
+                                            );
+
+                                            ModelObjectId modelObjectId = defaultTenantBuilder()
+                                                    .addChild(DefaultFpcMobility.class)
+                                                    .build();
+                                            updateNode(convertContext(context), modelObjectId);
+                                        }));
                                     } else {
 //                                        tasks.add(Executors.callable(() ->
 //                                                dpnCommunicationService.delete_bearer(
@@ -438,17 +485,22 @@
                                 }
                                 if (commands.contains("uplink")) {
                                     if (context.ul().lifetime() >= 0L) {
-                                        tasks.add(Executors.callable(() ->
-                                                dpnCommunicationService.modify_bearer(
-                                                        topic_id,
-                                                        s1u_sgw_ipv4,
-                                                        s1u_enb_gtpu_teid,
-                                                        s1u_enodeb_ipv4,
-                                                        contextId,
-                                                        cId,
-                                                        opId
-                                                )
-                                        ));
+                                        tasks.add(Executors.callable(() -> {
+                                            dpnCommunicationService.modify_bearer(
+                                                    topic_id,
+                                                    s1u_sgw_ipv4,
+                                                    s1u_enb_gtpu_teid,
+                                                    s1u_enodeb_ipv4,
+                                                    contextId,
+                                                    cId,
+                                                    opId
+                                            );
+
+                                            ModelObjectId modelObjectId = defaultTenantBuilder()
+                                                    .addChild(DefaultFpcMobility.class)
+                                                    .build();
+                                            updateNode(convertContext(context), modelObjectId);
+                                        }));
                                     } else {
 //                                        tasks.add(Executors.callable(() ->
 //                                                dpnCommunicationService.delete_bearer(
@@ -464,16 +516,20 @@
                         } else {
                             throw new IllegalArgumentException("DPN does not have node and network ID defined.");
                         }
+                    } else {
+                        throw new IllegalArgumentException("No 3GPP instructions where given.");
                     }
                 }
             }
 
+            // execute all tasks.
             ExecutorService executor = Executors.newWorkStealingPool();
             executor.invokeAll(tasks).forEach(
                     future -> {
                         try {
                             future.get();
                         } catch (Exception e) {
+                            log.error(ExceptionUtils.getFullStackTrace(e));
                             throw new IllegalStateException(e);
                         }
                     }
@@ -481,16 +537,11 @@
 
             configureOutput.resultType(defaultCommonSuccess);
             configureOutput.result(Result.of(ResultEnum.OK));
-
-            update.contexts().forEach(
-                    contexts -> getDefaultTenant().ifPresent(
-                            tenant -> tenant.fpcMobility().addToContexts(convertContext(contexts))
-                    )
-            );
         } catch (Exception e) {
+            // if there is an exception respond with an error.
             log.error(ExceptionUtils.getFullStackTrace(e));
             DefaultErr defaultErr = new DefaultErr();
-            defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+            defaultErr.errorInfo(ExceptionUtils.getMessage(e));
             defaultErr.errorTypeId(ErrorTypeId.of(0));
             configureOutput.resultType(defaultErr);
             configureOutput.result(Result.of(ResultEnum.ERR));
@@ -499,6 +550,7 @@
         return configureOutput;
     }
 
+    @Override
     public DefaultConfigureOutput configureDelete(
             DeleteOrQuery delete,
             ClientIdentifier clientId,
@@ -506,14 +558,16 @@
     ) {
         DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
         Collection<Callable<Object>> tasks = new ArrayList<>();
-        DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
         try {
+            DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
             for (Targets target : delete.targets()) {
                 defaultDeleteSuccess.addToTargets(target);
+                // parse context id.
                 String targetStr = target.target().toString(),
                         s = StringUtils.substringBetween(targetStr, "contexts=", "/"),
                         trgt = s != null ? s : StringUtils.substringAfter(targetStr, "contexts=");
 
+                // find context that this target is about.
                 getDefaultTenant().map(
                         tenant -> {
                             if (tenant.fpcMobility().contexts() != null) {
@@ -531,6 +585,18 @@
                 ).ifPresent(
                         context -> context.dpns().forEach(
                                 dpn -> {
+                                    // check if dpns exists and if there is a DPN registered for the wanted identifier.
+                                    if (getDefaultTenant().map(
+                                            tenant -> tenant.fpcTopology().dpns() == null ||
+                                                    tenant.fpcTopology().dpns()
+                                                            .stream()
+                                                            .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
+                                    ).orElse(false)) {
+                                        // throw exception if DPN ID is not registered.
+                                        throw new IllegalStateException("DPN ID is not registered to the topology.");
+                                    }
+
+                                    // from DPN ID find the Network and Node Identifiers
                                     Optional<String> key = getDefaultTenant().flatMap(tenant ->
                                             tenant.fpcTopology()
                                                     .dpns()
@@ -540,10 +606,13 @@
                                     );
 
                                     if (key.isPresent()) {
-                                        Short topic_id = FpcUtil.getTopicFromNode(key.get());
+                                        // find DPN Topic from Node/Network ID pair.
+                                        Short topic_id = getTopicFromNode(key.get());
 
                                         if (topic_id != null) {
+
                                             Long teid;
+
                                             if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
                                                 teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
                                             } else {
@@ -553,6 +622,7 @@
                                             long client_id = clientId.fpcIdentity().union().int64();
                                             BigInteger op_id = operationId.uint64();
 
+                                            // TODO figure out what is going on.
                                             if (targetStr.endsWith("ul") || targetStr.endsWith("dl")) {
 //                                                tasks.add(Executors.callable(() -> {
 //                                                    dpnCommunicationService.delete_bearer(
@@ -572,11 +642,14 @@
                                                             op_id
                                                     );
 
-                                                    getDefaultTenant().ifPresent(
-                                                            tenant -> tenant.fpcMobility()
-                                                                    .contexts()
-                                                                    .remove(context)
-                                                    );
+                                                    ContextsKeys contextsKeys = new ContextsKeys();
+                                                    contextsKeys.contextId(context.contextId());
+
+                                                    ResourceId resourceVal = getResourceVal(defaultTenantBuilder()
+                                                            .addChild(DefaultFpcMobility.class)
+                                                            .addChild(DefaultContexts.class, contextsKeys)
+                                                            .build());
+                                                    dynamicConfigService.deleteNode(resourceVal);
                                                 }));
                                             }
 
@@ -592,12 +665,14 @@
 
             }
 
+            // execute all tasks
             ExecutorService executor = Executors.newWorkStealingPool();
             executor.invokeAll(tasks).forEach(
                     future -> {
                         try {
                             future.get();
                         } catch (Exception e) {
+                            log.error(ExceptionUtils.getFullStackTrace(e));
                             throw new IllegalStateException(e);
                         }
                     }
@@ -605,12 +680,12 @@
 
             configureOutput.resultType(defaultDeleteSuccess);
             configureOutput.result(Result.of(ResultEnum.OK));
-
         } catch (Exception e) {
+            // if there is an exception respond with an error.
             log.error(ExceptionUtils.getFullStackTrace(e));
             DefaultErr defaultErr = new DefaultErr();
             configureOutput.resultType(defaultErr);
-            defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+            defaultErr.errorInfo(ExceptionUtils.getMessage(e));
             defaultErr.errorTypeId(ErrorTypeId.of(0));
         }
 
@@ -618,6 +693,26 @@
     }
 
     /**
+     * Extract Resource Data from specified DataNode and Resource Id.
+     *
+     * @param dataNode DataNode
+     * @param resId    Resource Identifier
+     * @return Resource Data
+     */
+    private ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
+        if (resId != null) {
+            return DefaultResourceData.builder()
+                    .addDataNode(dataNode)
+                    .resourceId(resId)
+                    .build();
+        } else {
+            return DefaultResourceData.builder()
+                    .addDataNode(dataNode)
+                    .build();
+        }
+    }
+
+    /**
      * Accumulates events to allow processing after a desired number of
      * events were accumulated.
      */
@@ -638,14 +733,13 @@
                         switch (event.type()) {
                             case NODE_ADDED:
                             case NODE_DELETED:
-                                Filter filter = Filter.builder().build();
-                                DataNode node = dynamicConfigService.readNode(tenantsResourceId, filter);
-                                getModelObjects(node, null).forEach(
-                                        modelObject -> fpcAgentData.tenants((DefaultTenants) modelObject)
-                                );
-                                break;
                             case NODE_UPDATED:
                             case NODE_REPLACED:
+//                                Filter filter = Filter.builder().build();
+//                                DataNode node = dynamicConfigService.readNode(FpcUtil.tenants, filter);
+//                                getModelObjects(node, null).forEach(
+//                                        modelObject -> fpcAgentData.tenants((DefaultTenants) modelObject)
+//                                );
                                 break;
                             default:
                                 log.warn(UNKNOWN_EVENT, event.type());
@@ -669,10 +763,11 @@
          * @return true if event is supported; false otherwise
          */
         private boolean isSupported(DynamicConfigEvent event) {
-            ResourceId rsId = event.subject();
-            List<NodeKey> storeKeys = rsId.nodeKeys();
-            List<NodeKey> tenantKeys = tenantsResourceId.nodeKeys();
-            return storeKeys.size() >= 2 && storeKeys.get(0).equals(tenantKeys.get(1));
+//            ResourceId rsId = event.subject();
+//            List<NodeKey> storeKeys = rsId.nodeKeys();
+//            List<NodeKey> tenantKeys = FpcUtil.tenants.nodeKeys();
+//            return storeKeys.size() >= 2 && storeKeys.get(0).equals(tenantKeys.get(1));
+            return true;
         }
 
         @Override
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
index 4b88510..2542858 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
@@ -7,48 +7,105 @@
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.Tenant;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObject;
-import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.*;
 
 import java.util.List;
 import java.util.Optional;
 
 @Beta
 public interface TenantService {
+    /**
+     * Returns the root level node for Tenants.
+     * Tenants is an interface that includes a List of Tenant objects.
+     *
+     * @return Optional Tenants
+     */
     Optional<DefaultTenants> getTenants();
 
-    void createNode(InnerModelObject innerModelObject);
+    /**
+     * Creates a Node inside the Dynamic Configuration Store.
+     *
+     * @param innerModelObject inner model object to create
+     * @param modelObjectId    Model Object ID
+     */
+    void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
 
-    void updateNode(InnerModelObject innerModelObject);
+    /**
+     * Updates a Node inside the Dynamic Configuration Store.
+     *
+     * @param innerModelObject inner model object to update
+     * @param modelObjectId    Model Object ID
+     */
+    void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
 
+    /**
+     * Converts DataNode to a ModelObject.
+     *
+     * @param dataNode DataNode
+     * @param appId    Resource Identifier
+     * @return Model Object
+     */
     List<ModelObject> getModelObjects(DataNode dataNode, ResourceId appId);
 
-    Optional<Tenant> getDefaultTenant();
+    /**
+     * Returns the Default Tenant.
+     *
+     * @return Optional Default Tenant
+     */
+    Optional<DefaultTenant> getDefaultTenant();
 
-    Optional<Tenant> getTenant(FpcIdentity tenantId);
+    /**
+     * Get Tenant by its Identifier.
+     *
+     * @param tenantId Tenant Identifier
+     * @return Optional Tenant
+     */
+    Optional<DefaultTenant> getTenant(FpcIdentity tenantId);
 
-    Optional<Tenant> getTenant(ClientIdentifier clientId);
+    Optional<DefaultTenant> getTenant(ClientIdentifier clientId);
 
-    Optional<Tenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId);
+    Optional<DefaultTenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId);
 
-    Optional<Tenant> deregisterClient(ClientIdentifier clientId);
+    Optional<DefaultTenant> deregisterClient(ClientIdentifier clientId);
 
+    /**
+     * Handles create configure operations that are invoked through RPC.
+     *
+     * @param create      RPC Input converted
+     * @param clientId    Client Identifier
+     * @param operationId Operation Identifier
+     * @return Result of the configuration
+     */
     DefaultConfigureOutput configureCreate(
             CreateOrUpdate create,
             ClientIdentifier clientId,
             OpIdentifier operationId
     );
 
+    /**
+     * Handles update configure operations that are invoked through RPC.
+     *
+     * @param update      RPC Input converted
+     * @param clientId    Client Identifier
+     * @param operationId Operation Identifier
+     * @return Result of the configuration
+     */
     DefaultConfigureOutput configureUpdate(
-            CreateOrUpdate create,
+            CreateOrUpdate update,
             ClientIdentifier clientId,
             OpIdentifier operationId
     );
 
+    /**
+     * Handles delete configure operations that are invoked through RPC.
+     *
+     * @param delete      RPC Input converted
+     * @param clientId    Client Identifier
+     * @param operationId Operation Identifier
+     * @return Result of the configuration
+     */
     DefaultConfigureOutput configureDelete(
             DeleteOrQuery delete,
             ClientIdentifier clientId,
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
index d023cb8..c47bdd0 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
@@ -1,7 +1,6 @@
 package org.onosproject.fpcagent.helpers;
 
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.Contexts;
 import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
 import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnGroupId;
@@ -113,8 +112,8 @@
     public static Function<String, FpcIdentity> getFpcIdentity = (v) -> new FpcIdentity(new FpcIdentityUnion(v));
     public static Function<String, ClientIdentifier> getClientIdentity = (v) -> new ClientIdentifier(getFpcIdentity.apply(v));
 
-    public static Contexts convertContext(org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.payload.Contexts contexts) {
-        Contexts ctx = new DefaultContexts();
+    public static DefaultContexts convertContext(org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.payload.Contexts contexts) {
+        DefaultContexts ctx = new DefaultContexts();
         FpcContextId fpcContextId = contexts.contextId();
         List<IpPrefix> ipPrefixes = contexts.delegatingIpPrefixes();
         Dl dl = contexts.dl();
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
index 88dc2b5..9785a41 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
@@ -20,57 +20,76 @@
 
 import java.math.BigInteger;
 
+/**
+ * Communication Service which sends packets to desired DPNs.
+ */
 public interface DpnCommunicationService {
-    /**
-     * Creates Mobility Session
-     *  @param topicId           - DPN
-     * @param imsi              - IMSI
-     * @param default_ebi       - Default EBI
-     */
-    void create_session(
-            Short topicId,
-            BigInteger imsi,
-            Short default_ebi, Ip4Address ue_ipv4,
-            Long s1u_sgw_teid, Ip4Address s1u_sgw_ipv4,
-            Long session_id, Long client_id,
-            BigInteger op_id
-    );
 
     /**
-     * Modify Downlink Bearer.
-     *  @param topic_id         - DPN
-     * @param s1u_sgw_ipv4    - SGW GTP-U IPv4 Address
-     * @param s1u_enodeb_teid - ENodeB TEID
-     * @param s1u_enodeb_ipv4 - ENodeB GTP-U IPv4 Address
-     * @param session_id       - Session Id
-     * @param client_id        - Operation Identifier
-     * @param op_id            - Session Id
+     * Creates Mobility Session.
+     *
+     * @param topic_id     - DPN Topic ID
+     * @param imsi         - IMSI identifier
+     * @param default_ebi  - EBI
+     * @param ue_ipv4      - UE IPv4 Address
+     * @param s1u_sgw_teid - SGW Tunnel Identifier
+     * @param s1u_sgw_ipv4 - SGW IPv4
+     * @param session_id   - Context Identifier
+     * @param client_id    - Client Identifier
+     * @param op_id        - Operation Identifier
      */
-    void modify_bearer(
+    void create_session(
             Short topic_id,
-            Ip4Address s1u_sgw_ipv4, Long s1u_enodeb_teid, Ip4Address s1u_enodeb_ipv4,
+            BigInteger imsi,
+            Short default_ebi,
+            Ip4Address ue_ipv4,
+            Long s1u_sgw_teid,
+            Ip4Address s1u_sgw_ipv4,
             Long session_id,
             Long client_id,
             BigInteger op_id
     );
 
     /**
-     * DeleteOrQuery Mobility Session.
-     *  @param topic_id          - DPN
-     * @param session_id        - Session Id
-     * @param client_id - Client Identifier
-     * @param op_id     - Operation Identifier
+     * Modifies Bearer.
+     *
+     * @param topic_id        - DPN Topic ID
+     * @param s1u_sgw_ipv4    - SGW IPv4 Address
+     * @param s1u_enodeb_teid - ENodeB Tunnel Identifier
+     * @param s1u_enodeb_ipv4 - ENodeB IPv4 Address
+     * @param session_id      - Context Identifier
+     * @param client_id       - Client Identifier
+     * @param op_id           - Operation Identifier
+     */
+    void modify_bearer(
+            Short topic_id,
+            Ip4Address s1u_sgw_ipv4,
+            Long s1u_enodeb_teid,
+            Ip4Address s1u_enodeb_ipv4,
+            Long session_id,
+            Long client_id,
+            BigInteger op_id
+    );
+
+    /**
+     * Deletes Mobility Session.
+     *
+     * @param topic_id   - DPN Topic ID
+     * @param session_id - Context Identifier
+     * @param client_id  - Client Identifier
+     * @param op_id      - Operation Identifier
      */
     void delete_session(
             Short topic_id,
-            Long session_id, Long client_id,
+            Long session_id,
+            Long client_id,
             BigInteger op_id
     );
 
     /**
      * Creates the byte buffer to send ADC rules over ZMQ
      *
-     * @param topic        - DPN Topic
+     * @param topic        - DPN Topic ID
      * @param domain_name  - domain
      * @param ip           - ipaddress/ipprefix (i.e. 127.0.0.1/32)
      * @param drop         - Drop if 1
@@ -80,8 +99,11 @@
      */
     void send_ADC_rules(
             Short topic,
-            String domain_name, String ip,
-            Short drop, Long rating_group,
-            Long service_ID, String sponsor_ID
+            String domain_name,
+            String ip,
+            Short drop,
+            Long rating_group,
+            Long service_ID,
+            String sponsor_ID
     );
 }
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
index e93eb09..a315b55 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
@@ -1,5 +1,20 @@
-package org.onosproject.fpcagent.helpers;
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
+package org.onosproject.fpcagent.helpers;
 
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.Ip4Prefix;
@@ -14,7 +29,7 @@
 import static org.onosproject.fpcagent.helpers.Converter.*;
 
 /**
- * DPDK DPN API over ZeroMQ.
+ * DPDK DPN API over ZeroMQ for NGIC.
  */
 public class DpnNgicCommunicator implements DpnCommunicationService {
     protected static final Logger log = LoggerFactory.getLogger(DpnNgicCommunicator.class);
@@ -133,7 +148,6 @@
         ZMQSBPublisherManager.getInstance().send(bb);
     }
 
-
     @Override
     public void send_ADC_rules(
             Short topic,
@@ -143,6 +157,7 @@
             Long rating_group,
             Long service_ID, String sponsor_ID
     ) {
+        // TODO take a look for this function. Not tested.
         Ip4Prefix ip_prefix = null;
         if (ip != null) {
             ip_prefix = Ip4Prefix.valueOf(ip);
@@ -185,6 +200,8 @@
 
     /**
      * Following the NGIC message types.
+     *
+     * This type structure is defined in NGIC at interface/zmq/zmqsub.h:51
      */
     enum s11MsgType {
         CREATE_SESSION(1),
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
index f259883..7a53aaa 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
@@ -143,7 +143,7 @@
         String node_id = new String(Arrays.copyOfRange(contents, 8, 8 + nodeIdLen));
         String network_id = new String(Arrays.copyOfRange(contents, 9 + nodeIdLen, 9 + nodeIdLen + networkIdLen));
 
-        if (toUint8(subscriberId) == topic || nodeId.equals(node_id) || networkId.equals(network_id)) {
+        if (toUint8(subscriberId) == topic || (nodeId.equals(node_id) && networkId.equals(network_id))) {
             ByteBuffer bb = ByteBuffer.allocate(9 + nodeId.length() + networkId.length());
             bb.put(toUint8(broadcastAllId))
                     .put(ASSIGN_CONFLICT)
