Cleaned up the Rib class and renamed it to RibEntry
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
index 1825fed..1b55cd6 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -334,7 +334,7 @@
 	
 	// Return nexthop address as byte array.
 	/*
-	public Rib lookupRib(byte[] dest) {
+	public RibEntry lookupRib(byte[] dest) {
 		if (ptree == null) {
 		    log.debug("lookupRib: ptree null");
 		    return null;
@@ -470,7 +470,7 @@
 			}
 			
 			//PtreeNode node = ptree.acquire(p.getAddress(), p.getPrefixLength());
-			Rib rib = new Rib(router_id, nexthop, p.getPrefixLength());
+			RibEntry rib = new RibEntry(router_id, nexthop);
 			
 			/*
 			if (node.rib != null) {
@@ -501,7 +501,7 @@
 		Prefix prefix = update.getPrefix();
 		
 		//PtreeNode node = ptree.acquire(prefix.getAddress(), prefix.getPrefixLength());
-		Rib rib = ptree.put(prefix, update.getRibEntry());
+		RibEntry rib = ptree.put(prefix, update.getRibEntry());
 		
 		//if (node.rib != null) {
 		if (rib != null && !rib.equals(update.getRibEntry())) {
@@ -568,7 +568,7 @@
 		addPrefixFlows(prefix, node.rib);
 	}*/
 
-	private void addPrefixFlows(Prefix prefix, Rib rib) {
+	private void addPrefixFlows(Prefix prefix, RibEntry rib) {
 		if (!topologyReady){
 			return;
 		}
@@ -578,16 +578,15 @@
 		//I think we'll have to make prefixAdded and prefixDelete atomic as well
 		//to protect against the prefix getting deleted while where trying to add it
 
-		log.debug("New prefix {} added, next hop {}, routerId {}", 
-				new Object[] {prefix, rib.nextHop.getHostAddress(),
-				rib.routerId.getHostAddress()});
+		log.debug("New prefix {} added, next hop {}", 
+				prefix, rib.getNextHop().getHostAddress());
 		
 		//TODO this is wrong, we shouldn't be dealing with BGP peers here.
 		//We need to figure out where the device is attached and what its
 		//mac address is by learning. 
 		//The next hop is not necessarily the peer, and the peer's attachment
 		//point is not necessarily the next hop's attachment point.
-		BgpPeer peer = bgpPeers.get(rib.nextHop);
+		BgpPeer peer = bgpPeers.get(rib.getNextHop());
 		
 		if (peer == null){
 			//TODO local router isn't in peers list so this will get thrown
@@ -596,7 +595,7 @@
 			//The other scenario is this is a route server route. In that
 			//case the next hop is not in our configuration
 			log.error("Couldn't find next hop router in router {} in config",
-					rib.nextHop.getHostAddress());
+					rib.getNextHop().getHostAddress());
 			return; //just quit out here? This is probably a configuration error
 		}
 		
@@ -1042,10 +1041,10 @@
 				
 				//addPrefixFlows(update.getPrefix(), update.getRibEntry());
 				//processRibAdd(update);
-				Rib rib = ptree.lookup(update.getPrefix()); 
+				RibEntry rib = ptree.lookup(update.getPrefix()); 
 				if (rib != null && rib.equals(update.getRibEntry())) {
 					log.debug("Pushing prefix {} next hop {}", update.getPrefix(), 
-							rib.nextHop.getHostAddress());
+							rib.getNextHop().getHostAddress());
 					//We only push prefix flows if the prefix is still in the ptree
 					//and the next hop is the same as our update. The prefix could 
 					//have been removed while we were waiting for the ARP, or the 
@@ -1178,14 +1177,11 @@
 
 	@Override
 	public void topologyChanged() {		
-		//There seems to be more topology events than there should be. Lots of link
-		//updated, port up and switch updated on what should be a fairly static topology
-		
 		boolean refreshNeeded = false;
 		for (LDUpdate ldu : topology.getLastLinkUpdates()){
 			if (!ldu.getOperation().equals(ILinkDiscovery.UpdateOperation.LINK_UPDATED)){
 				//We don't need to recalculate anything for just link updates
-				//They happen way too frequently (may be a bug in our link discovery)
+				//They happen very frequently
 				refreshNeeded = true;
 			}
 			
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRouteResource.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRouteResource.java
index 2c9d284..c9b3265 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRouteResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRouteResource.java
@@ -147,7 +147,7 @@
 				return reply + "\n";
 			}
 			
-			Rib rib = new Rib(routerId, nexthop, p.getPrefixLength());
+			RibEntry rib = new RibEntry(routerId, nexthop);
 
 			bgpRoute.newRibUpdate(new RibUpdate(Operation.UPDATE, p, rib));
 			
@@ -210,7 +210,7 @@
 				return reply + "\n";
 			}
 			
-			Rib r = new Rib(routerId, nextHop, p.getPrefixLength());
+			RibEntry r = new RibEntry(routerId, nextHop);
 			
 			bgpRoute.newRibUpdate(new RibUpdate(Operation.DELETE, p, r));
 			
@@ -242,7 +242,7 @@
 		else {
 			// clear the local rib: Ptree			
 			bgpRoute.clearPtree();
-			reply = "[DELE-capability: " + capability + "; The local Rib is cleared!]\n";
+			reply = "[DELE-capability: " + capability + "; The local RibEntry is cleared!]\n";
 
 			// to store the number in the top node of the Ptree	
 		}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/IBgpRouteService.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/IBgpRouteService.java
index b355c4b..ba912ce 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/IBgpRouteService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/IBgpRouteService.java
@@ -4,7 +4,7 @@
 
 public interface IBgpRouteService extends IFloodlightService {
 
-	//public Rib lookupRib(byte[] dest);
+	//public RibEntry lookupRib(byte[] dest);
 
 	//public Ptree getPtree();
 	public IPatriciaTrie getPtree();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/IPatriciaTrie.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/IPatriciaTrie.java
index 9ec50bf..7fd7382 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/IPatriciaTrie.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/IPatriciaTrie.java
@@ -3,18 +3,18 @@
 import java.util.Iterator;
 
 public interface IPatriciaTrie {
-	public Rib put(Prefix p, Rib r);
+	public RibEntry put(Prefix p, RibEntry r);
 	
-	public Rib lookup(Prefix p);
+	public RibEntry lookup(Prefix p);
 	
-	public Rib match(Prefix p);
+	public RibEntry match(Prefix p);
 	
-	public boolean remove(Prefix p, Rib r);
+	public boolean remove(Prefix p, RibEntry r);
 	
 	public Iterator<Entry> iterator();
 	
 	interface Entry {
 		public Prefix getPrefix();
-		public Rib getRib();
+		public RibEntry getRib();
 	}
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PatriciaTrie.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PatriciaTrie.java
index 514758f..86bc8cf 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PatriciaTrie.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PatriciaTrie.java
@@ -15,7 +15,7 @@
 		this.maxPrefixLength = maxPrefixLength;
 	}
 
-	public synchronized Rib put(Prefix p, Rib r) {
+	public synchronized RibEntry put(Prefix p, RibEntry r) {
 		if (p.getPrefixLength() > maxPrefixLength) {
 			throw new IllegalArgumentException(String.format(
 					"Prefix length %d is greater than max prefix length %d", 
@@ -39,7 +39,7 @@
 		    	 * case we are inserting a new nexthop for the prefix and should return
 		    	 * the old nexthop.
 		    	 */
-		    	Rib oldRib = node.rib;
+		    	RibEntry oldRib = node.rib;
 		    	node.rib = r;
 		    	return oldRib;
 			}
@@ -94,7 +94,7 @@
 	}
 	
 	/*exact match*/
-	public synchronized Rib lookup(Prefix p) {
+	public synchronized RibEntry lookup(Prefix p) {
 		//TODO
 		
 		if (p.getPrefixLength() > maxPrefixLength) {
@@ -126,12 +126,12 @@
 	}
 	
 	/*closest containing prefix*/
-	public synchronized Rib match(Prefix p) {
+	public synchronized RibEntry match(Prefix p) {
 		//TODO
 		return null;
 	}
 	
-	public synchronized boolean remove(Prefix p, Rib r) {
+	public synchronized boolean remove(Prefix p, RibEntry r) {
 		Node child;
 		Node parent;
 		
@@ -147,7 +147,7 @@
 		}
 		
 		if (node.left != null && node.right != null) {
-			//Remove the Rib entry and leave this node as an aggregate node
+			//Remove the RibEntry entry and leave this node as an aggregate node
 			//In the future, maybe we should re-evaluate what the aggregate prefix should be?
 			//It shouldn't necessarily stay the same.
 			//More complicated if the above prefix is also aggregate.
@@ -313,7 +313,7 @@
 		
 		//Creating a new Prefix with a prefix length of common_len
 		//Bits are copied from node's up until the common_len'th bit
-		//Rib is null, because this is an aggregate prefix - it's not
+		//RibEntry is null, because this is an aggregate prefix - it's not
 		//actually been added to the trie.
 		
 		byte[] newPrefix = new byte[getByteContainingBit(maxPrefixLength)];
@@ -335,9 +335,9 @@
 		public Node right = null;
 		
 		public Prefix prefix;
-		public Rib rib;
+		public RibEntry rib;
 		
-		public Node(Prefix p, Rib r) {
+		public Node(Prefix p, RibEntry r) {
 			this.prefix = p;
 			this.rib = r;
 		}
@@ -349,9 +349,9 @@
 	
 	private class PatriciaTrieEntry implements Entry {
 		private Prefix prefix;
-		private Rib rib;
+		private RibEntry rib;
 		
-		public PatriciaTrieEntry(Prefix prefix, Rib rib) {
+		public PatriciaTrieEntry(Prefix prefix, RibEntry rib) {
 			this.prefix = prefix;
 			this.rib = rib;
 		}
@@ -362,7 +362,7 @@
 		}
 		
 		@Override
-		public Rib getRib() {
+		public RibEntry getRib() {
 			return rib;
 		}
 	}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PtreeNode.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PtreeNode.java
index a4d6996..50b7c7d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/PtreeNode.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/PtreeNode.java
@@ -13,7 +13,7 @@
 	
 	public int refCount;
 	
-	public Rib rib;
+	public RibEntry rib;
 	protected static Logger log = LoggerFactory.getLogger(BgpRoute.class);
 	
 	PtreeNode(byte [] key, int key_bits, int max_key_octet) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Rib.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/Rib.java
deleted file mode 100644
index dc5f71d..0000000
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/Rib.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.onrc.onos.ofcontroller.bgproute;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class Rib {
-	protected InetAddress routerId;
-	protected InetAddress nextHop;
-	protected int masklen;
-//	protected int distance;
-	
-	Rib(InetAddress router_id, InetAddress nexthop, int masklen) {
-		this.routerId = router_id;
-		this.nextHop = nexthop;
-		this.masklen = masklen;
-//		this.distance = distance;
-	}
-	
-	Rib(String router_id, String nexthop, int masklen) {
-		try {
-			this.routerId = InetAddress.getByName(router_id);
-		} catch (UnknownHostException e) {
-			System.out.println("InetAddress exception");
-		}
-		try {
-			this.nextHop = InetAddress.getByName(nexthop);
-		} catch (UnknownHostException e) {
-			System.out.println("InetAddress exception");
-		}
-		this.masklen = masklen;
-	}
-	
-	public InetAddress getNextHop() {
-	    return nextHop;
-	}
-	
-	public int getMasklen(){
-	    return masklen;
-	}
-	
-	public boolean equals(Rib r) {
-				
-		return this.routerId.equals(r.routerId) && this.nextHop.equals(r.nextHop)  && this.masklen == r.masklen;
-		
-	}
-}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java
new file mode 100644
index 0000000..c27f962
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibEntry.java
@@ -0,0 +1,47 @@
+package net.onrc.onos.ofcontroller.bgproute;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class RibEntry {
+	private InetAddress routerId;
+	private InetAddress nextHop;
+	
+	public RibEntry(InetAddress routerId, InetAddress nextHop) {
+		this.routerId = routerId;
+		this.nextHop = nextHop;
+	}
+	
+	public RibEntry(String routerId, String nextHop) {
+		try {
+			this.routerId = InetAddress.getByName(routerId);
+			this.nextHop = InetAddress.getByName(nextHop);
+		} catch (UnknownHostException e) {
+			throw new IllegalArgumentException("Invalid address format");
+		}
+	}
+	
+	public InetAddress getNextHop() {
+	    return nextHop;
+	}
+	
+	@Override
+	public boolean equals(Object other) {
+		if (other == null || !(other instanceof RibEntry)) {
+			return false;
+		}
+		
+		RibEntry otherRibEntry = (RibEntry) other;
+		
+		return this.routerId.equals(otherRibEntry.routerId) 
+				&& this.nextHop.equals(otherRibEntry.nextHop);
+	}
+	
+	@Override
+	public int hashCode() {
+		int hash = 17;
+		hash = 31 * hash + routerId.hashCode();
+		hash = 31 * hash + nextHop.hashCode();
+		return hash;
+	}
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
index c7272bd..7d4d7a5 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/RibUpdate.java
@@ -5,9 +5,9 @@
 	
 	private Operation operation;
 	private Prefix prefix;
-	private Rib ribEntry;
+	private RibEntry ribEntry;
 	
-	public RibUpdate(Operation operation, Prefix prefix, Rib ribEntry) {
+	public RibUpdate(Operation operation, Prefix prefix, RibEntry ribEntry) {
 		this.operation = operation;
 		this.prefix = prefix;
 		this.ribEntry = ribEntry;
@@ -21,7 +21,7 @@
 		return prefix;
 	}
 
-	public Rib getRibEntry() {
+	public RibEntry getRibEntry() {
 		return ribEntry;
 	}
 }