diff --git a/mininet/conf_parser.py b/mininet/conf_parser.py
index c9fe119..2e8014c 100644
--- a/mininet/conf_parser.py
+++ b/mininet/conf_parser.py
@@ -1,49 +1,49 @@
 import ConfigParser, re
 
 class confCCNHost():
-    
+
     def __init__(self, name, app='', uri_tuples='', cpu=None, cores=None):
         self.name = name
         self.app = app
         self.uri_tuples = uri_tuples
         self.cpu = cpu
         self.cores = cores
-        
+
     def __repr__(self):
         return 'Name: ' + self.name + ' App: ' + self.app + ' URIS: ' + str(self.uri_tuples) + ' CPU:' + str(self.cpu) + ' Cores:' +str(self.cores)
 
 class confCCNLink():
-    
+
     def __init__(self,h1,h2,linkDict=None):
         self.h1 = h1
         self.h2 = h2
         self.linkDict = linkDict
-        
+
     def __repr__(self):
         return 'h1: ' + self.h1 + ' h2: ' + self.h2 + ' params: ' + str(self.linkDict)
-    
+
 def parse_hosts(conf_arq):
     'Parse hosts section from the conf file.'
     config = ConfigParser.RawConfigParser()
     config.read(conf_arq)
-    
+
     hosts = []
-    
+
     items = config.items('hosts')
-    
+
     for item in items:
 
         name = item[0]
-  
+
         rest = item[1].split()
 
         app = rest.pop(0)
-        
+
         uris = rest
         uri_list=[]
         cpu = None
         cores = None
-        
+
         for uri in uris:
             if re.match("cpu",uri):
                 cpu = float(uri.split('=')[1])
@@ -51,9 +51,9 @@
                 cores = uri.split('=')[1]
             else:
                 uri_list.append((uri.split(',')[0],uri.split(',')[1]))
-        
+
         hosts.append(confCCNHost(name , app, uri_list,cpu,cores))
-    
+
     return hosts
 
 def parse_routers(conf_arq):
@@ -62,65 +62,66 @@
     config.read(conf_arq)
 
     routers = []
-    
+
     items = config.items('routers')
-    
+
     for item in items:
         name = item[0]
-  
+
         rest = item[1].split()
 
         uris = rest
         uri_list=[]
         cpu = None
         cores = None
-        
+
         for uri in uris:
             if re.match("cpu",uri):
                 cpu = float(uri.split('=')[1])
             elif re.match("cores",uri):
-                cores = uri.split('=')[1]    
+                cores = uri.split('=')[1]
             else:
                 uri_list.append((uri.split(',')[0],uri.split(',')[1]))
-        
+
         routers.append(confCCNHost(name=name , uri_tuples=uri_list, cpu=cpu, cores=cores))
-    
+
     return routers
 
 def parse_links(conf_arq):
     'Parse links section from the conf file.'
     arq = open(conf_arq,'r')
-    
+
     links = []
-     
+
     while True:
         line = arq.readline()
         if line == '[links]\n':
             break
-    
+
     while True:
         line = arq.readline()
         if line == '':
             break
-        
+
         args = line.split()
         h1, h2 = args.pop(0).split(':')
-        
+
         link_dict = {}
-        
+
         for arg in args:
             arg_name, arg_value = arg.split('=')
             key = arg_name
             value = arg_value
-            if key in ['loss','bw','jitter','max_queue_size']:
+            if key in ['bw','jitter','max_queue_size']:
                 value = int(value)
-            
+            if key in ['loss']:
+                value = float(value)
             link_dict[key] = value
-            
+
         links.append(confCCNLink(h1,h2,link_dict))
-        
-        
+
+
     return links
-        
-        
-    
+
+
+
diff --git a/mininet/node.py b/mininet/node.py
index f8ec8c9..7f3c4c7 100644
--- a/mininet/node.py
+++ b/mininet/node.py
@@ -553,7 +553,7 @@
     pass
 
 
-        
+
 class CPULimitedHost( Host ):
 
     "CPU limited host"
@@ -592,7 +592,7 @@
         "Return value of cgroup parameter"
         cmd = 'cgget -r %s.%s /%s' % (
             resource, param, self.name )
-        
+
         return int(quietRun( cmd ).split()[ -1 ] )
 
     def cgroupDel( self ):
@@ -721,29 +721,31 @@
 
     def __init__( self, name, **kwargs ):
 
-        
+
         Host.__init__( self, name, **kwargs )
         if not CCNHost.inited:
             CCNHost.init()
-           
+
+       # self.cmd("export CCND_DEBUG=6")
+       # self.cmd("export CCND_LOG=./log.{0}".format(self.name))
         self.cmd("export CCN_LOCAL_SOCKNAME=/tmp/.sock.ccnx.{0}".format(self.name))
         self.cmd("ccndstart")
         self.peerList = {}
 
     def config( self, fib=None, app=None, **params ):
-             
+
         r = Node.config( self, **params )
-        
+
         self.setParam( r, 'app', fib=fib )
         self.setParam( r, 'fib', app=app)
-        
+
         return r
-    
+
     def configCCN(self):
-        
+
         self.buildPeerIP()
         self.setFIB()
-    
+
     def buildPeerIP(self):
         for iface in self.intfList():
             link = iface.link
@@ -753,8 +755,8 @@
                     self.peerList[node2.name] = link.intf2.node.IP(link.intf2)
                 else:
                     self.peerList[node1.name] = link.intf1.node.IP(link.intf1)
-        
-        
+
+
     def setFIB(self):
 
         for name in self.params['fib']:
@@ -762,53 +764,57 @@
                 pass
             else:
                 self.insert_fib(name[0],self.peerList[name[1]])
-            
-        
+
+
     def insert_fib(self, uri, host):
         self.cmd('ccndc add {0} tcp {1}'.format(uri,host))
-        
+ #	 self.cmd('ccndc add {0} udp {1}'.format(uri,host))
+
     def terminate( self ):
         "Stop node."
         self.cmd('ccndstop')
+        self.cmd('killall -r zebra ospf')
         Host.terminate(self)
-        
+
     inited = False
 
-    
+
     @classmethod
     def init( cls ):
         "Initialization for CCNHost class"
         cls.inited = True
-        
+
 class CPULimitedCCNHost( CPULimitedHost ):
     '''CPULimitedCCNHost is a Host that always runs the ccnd daemon and extends CPULimitedHost.
        It should be used when one wants to limit the resources of CCN routers and hosts '''
-    
+
 
     def __init__( self, name, sched='cfs', **kwargs ):
-        
+
         CPULimitedHost.__init__( self, name, sched, **kwargs )
         if not CCNHost.inited:
             CCNHost.init()
-            
-        self.cmd("export CCN_LOCAL_SOCKNAME=/tmp/.sock.ccnx.{0}".format(self.name))
+
+       # self.cmd("export CCND_DEBUG=6")
+       # self.cmd("export CCND_LOG=./log.{0}".format(self.name))
+	self.cmd("export CCN_LOCAL_SOCKNAME=/tmp/.sock.ccnx.{0}".format(self.name))
         self.cmd("ccndstart")
         self.peerList = {}
 
-    def config( self, fib=None, app=None, cpu=None, cores=None, **params):   
+    def config( self, fib=None, app=None, cpu=None, cores=None, **params):
 
         r = CPULimitedHost.config(self,cpu,cores, **params)
-        
+
         self.setParam( r, 'app', fib=fib )
         self.setParam( r, 'fib', app=app)
-        
+
         return r
-    
+
     def configCCN(self):
-        
+
         self.buildPeerIP()
         self.setFIB()
-    
+
     def buildPeerIP(self):
         for iface in self.intfList():
             link = iface.link
@@ -818,8 +824,8 @@
                     self.peerList[node2.name] = link.intf2.node.IP(link.intf2)
                 else:
                     self.peerList[node1.name] = link.intf1.node.IP(link.intf1)
-        
-        
+
+
     def setFIB(self):
 
         for name in self.params['fib']:
@@ -827,19 +833,21 @@
                 pass
             else:
                 self.insert_fib(name[0],self.peerList[name[1]])
-            
-        
+
+
     def insert_fib(self, uri, host):
         self.cmd('ccndc add {0} tcp {1}'.format(uri,host))
-        
+#	self.cmd('ccndc add {0} udp {1}'.format(uri,host))
+
     def terminate( self ):
         "Stop node."
         self.cmd('ccndstop')
+        self.cmd('killall -r zebra ospf')
         Host.terminate(self)
-        
+
     inited = False
 
-    
+
     @classmethod
     def init( cls ):
         "Initialization for CCNHost class"
