 			else if peer.role is Peer.Role.Child
 				@removeChild(peer)
 
-
-		_onPeerSetSuperNode: (id, superNode) =>
+		# Is called when a peer switches supernode status. We will connect
+		# to all new supernodes when we're supernode.
+		#
+		# @param id [String] the string id the of the peer
+		# @param superNode [Boolean] the new supernode status of the peer
+		#
+		_onPeerSetSuperNode: ( id, superNode ) =>
 			unless peer = @getPeer(id)
 				if superNode and @isSuperNode
 					peer = @connect(id)
 					peer.once('channel.opened', =>
 						@addSibling(peer)
 					)
-			else
-				peer.isSuperNode = superNode
-
-		_enterNetwork: () =>
+			else peer.isSuperNode = superNode
+
+		# Attempts to enter the network by requesting a list of supernodes
+		# and selecting and connecting to a parent from the list.
+		#
+		_enterNetwork: ( ) =>
 
 			if @isSuperNode or @_parent?
 				return
 
-			connectParent =  (superNodes) =>
-
+			# Recursive submethod attempt connections to a list
+			# of nodes untill success.
+			connectParent =  ( superNodes ) =>
+				# If no available supernodes, we promote ourself.
 				if superNodes.length is 0
 					@setSuperNode(true)
 					return
 
-				i = _.random(0,superNodes.length-1)
+				# We pick a random supernode from the list.
+				i = _.random(0, superNodes.length - 1)
 				superNode = superNodes[i]
 				superNodes.splice(i, 1)
 
+				# If we're connected, just set as parent.
 				if peer = @getPeer(superNode.id)
-					@setParent(peer, (accepted) =>
+					@setParent(peer, ( accepted ) =>
 						unless accepted
 							connectParent(superNodes)
 					)
+				
+				# Else, first connect, then set as parent.
 				else
 					peer = @connect(superNode.id)
-					peer.once('channel.opened', () =>
-						@setParent(peer, (accepted) =>
+					peer.once('channel.opened', ( ) =>
+						@setParent(peer, ( accepted ) =>
 							unless accepted
 								connectParent(superNodes)
 						)
 					)
-
-			@server.query('nodes', 'node.structured', (nodes) =>
-				superNodes = _(nodes).filter( (node) -> node.isSuperNode)
-
-				if superNodes.length is 0
-					@setSuperNode(true)
-					return
-
+			# Query the server for nodes, and pass attempt to connect to supers.
+			@server.query('nodes', 'node.structured', ( nodes ) =>
+				superNodes = _(nodes).filter( ( node ) -> node.isSuperNode)
 				connectParent(superNodes)
-
 			)
 
-		_selectParent: () ->
+		# Selects the supernode with the lowest latency and attempts to connect.
+		# If this fails, try the next lowest latency.
+		#
+		_selectParent: ( ) ->
 
 			if @isSuperNode or @_parent?
 				return
 
+			# Recursive submethod attempt connections to a list
+			# of nodes untill success.
 			requestParent = (superNodes) =>
-
+				# If no supernode is left, request from the server.
 				if superNodes.length is 0
 					@_enterNetwork()
 					return
 
+				# Connect to the lowest latency node.
 				superNode = superNodes.shift()
-
 				@setParent(superNode, (accepted) =>
 					unless accepted
 						requestParent(superNodes)
 				)
 
+			# Compile a list of connected supernodes and sort by latency.
 			superNodes = _(@getPeers()).filter( (peer) -> peer.isSuperNode)
 			superNodes = _(superNodes).sortBy( (peer) -> peer.latency)
 			requestParent(superNodes)
 
+		# Ensures that the foundation of this node remains valid. Will do  this
+		# by connecting to supernodes when required, or setting a parent when we
+		# don't have one.
+		#
 		_updateFoundationNodes: () =>
-
-
+			# Make sure we have a parent when we need one.
+			if not @isSuperNode and not @_parent?
+				@_selectParent()
+				return
+
+			# Request all nodes from the server and set all supernodes as siblings.
 			if @isSuperNode
-				@server.query('nodes', 'node.structured', (nodes) =>
-					superNodes = _(nodes).filter( (node) -> node.isSuperNode)
+				@server.query('nodes', 'node.structured', ( nodes ) =>
+					superNodes = _(nodes).filter( ( node ) -> node.isSuperNode)
 
 					if superNodes.length is 0
 						return
 
 					for superNode in superNodes
-						( (superNode) =>
+						( ( superNode ) =>
 
 							if peer = @getPeer(superNode.id)
 								@addSibling(peer)
 							else
 								peer = @connect(superNode.id)
-								peer.once('channel.opened', () =>
+								peer.once('channel.opened', ( ) =>
 									@addSibling(peer)
 								)
 						) (superNode)
 				)
 
-			else unless @_parent?
-				@_selectParent()
-
+			# Ensure we are connected to enough supernodes to aid us in finding
+			# our correct position in the network and to catch our fall we we 
+			# lose our parent.
 			else
 				current = _(@getPeers()).filter( (peer) -> peer.isSuperNode).length
 				needed = @_foundationNodes - current
 				if needed <= 0 
 					return
 
-				@_parent.query('siblings', (superNodes) =>
+				@_parent.query('siblings', ( superNodes ) =>
 					if superNodes.length is 0
 						return 
 
-					superNodes = _(superNodes).filter( (node) => not @getPeer(node.id)?)
+					superNodes = _(superNodes).filter( ( node ) => not @getPeer(node.id)?)
 					n = Math.min(needed, superNodes.length)
 					while superNodes.length > n
 						i = _.random(0,superNodes.length-1)

		getSiblings: ( ) ->
			return @getPeers(Peer.Role.Sibling)

		setSuperNode: (superNode) ->
			if @isSuperNode is superNode
				return


			@token.candidates.push(candidate)

		# Selects the best candidate from all token candidates and passes our 
		# token to this candidate.
		#
		_selectTokenOwner: ( ) =>
			unless @token?
				return
