Hopefully the last bulk update for relays. Also includes a bunch of commenting.
Hopefully the last bulk update for relays. Also includes a bunch of commenting.

--- a/AntennaRange.cs
+++ b/AntennaRange.cs
@@ -43,6 +43,7 @@
 	 * */
 	public class ModuleLimitedDataTransmitter : ModuleDataTransmitter, IScienceDataTransmitter, IAntennaRelay
 	{
+		// Call this an antenna so that you don't have to.
 		[KSPField(isPersistant = true)]
 		protected bool IsAntenna = true;
 
@@ -78,13 +79,14 @@
 		[KSPField(isPersistant = false)]
 		public float maxDataFactor;
 
+		// This field exists to get saved to the persistence file so that relays can be found on unloaded Vessels.
 		[KSPField(isPersistant = true)]
 		protected float ARmaxTransmitDistance;
 
 		/*
 		 * Properties
 		 * */
-		// Returns the current distance to the center of Kerbin, which is totally where the Kerbals keep their radioes.
+		// Returns the parent vessel housing this antenna.
 		public new Vessel vessel
 		{
 			get
@@ -93,6 +95,7 @@
 			}
 		}
 
+		// Returns the distance to the nearest relay or Kerbin, whichever is closer.
 		public double transmitDistance
 		{
 			get
@@ -166,6 +169,7 @@
 			}
 		}
 
+		// Reports whether this antenna has been checked as a viable relay already in the current FindNearestRelay.
 		public bool relayChecked
 		{
 			get

--- a/AntennaRelay.cs
+++ b/AntennaRelay.cs
@@ -6,32 +6,47 @@
 {
 	public class AntennaRelay : IAntennaRelay
 	{
+		// We don't have a Bard, so we'll hide Kerbin here.
 		protected CelestialBody Kerbin;
 
+		/// <summary>
+		/// Gets the parent Vessel.
+		/// </summary>
+		/// <value>The parent Vessel.</value>
 		public Vessel vessel
 		{
 			get;
 			protected set;
 		}
 
-		// Returns the current distance to the center of Kerbin, which is totally where the Kerbals keep their radioes.
+		/// <summary>
+		/// Gets the transmit distance.
+		/// </summary>
+		/// <value>The transmit distance.</value>
 		public double transmitDistance
 		{
 			get
 			{
 				IAntennaRelay nearestRelay = this.FindNearestRelay();
 
+				// If there is no available relay nearby...
 				if (nearestRelay == null)
 				{
+					// .. return the distance to Kerbin
 					return this.DistanceTo(this.Kerbin);
 				}
 				else
 				{
+					/// ...otherwise, return the distance to the nearest available relay.
 					return this.DistanceTo(nearestRelay);
 				}
 			}
 		}
 
+		/// <summary>
+		/// The maximum distance at which this relay can operate.
+		/// </summary>
+		/// <value>The max transmit distance.</value>
 		public virtual float maxTransmitDistance
 		{
 			get;
@@ -49,6 +64,10 @@
 			protected set;
 		}
 
+		/// <summary>
+		/// Determines whether this instance can transmit.
+		/// </summary>
+		/// <returns><c>true</c> if this instance can transmit; otherwise, <c>false</c>.</returns>
 		public bool CanTransmit()
 		{
 			if (this.transmitDistance > this.maxTransmitDistance)
@@ -64,11 +83,13 @@
 		/// <summary>
 		/// Finds the nearest relay.
 		/// </summary>
-		/// <returns>The nearest relay.</returns>
+		/// <returns>The nearest relay or null, if no relays in range.</returns>
 		public IAntennaRelay FindNearestRelay()
 		{
+			// Set this relay as checked, so that we don't check it again.
 			this.relayChecked = true;
 
+			// Get a list of vessels within transmission range.
 			List<Vessel> nearbyVessels = FlightGlobals.Vessels
 				.Where(v => (v.GetWorldPos3D() - vessel.GetWorldPos3D()).magnitude < this.maxTransmitDistance)
 					.ToList();
@@ -79,6 +100,7 @@
 				nearbyVessels.Count
 				));
 
+			// Remove this vessel.
 			nearbyVessels.RemoveAll(v => v.id == vessel.id);
 
 			Tools.PostDebugMessage(string.Format(
@@ -87,6 +109,7 @@
 				nearbyVessels.Count
 				));
 
+			// Get a flattened list of all IAntennaRelay modules and protomodules in transmission range.
 			List<IAntennaRelay> nearbyRelays = nearbyVessels.SelectMany(v => v.GetAntennaRelays()).ToList();
 
 			Tools.PostDebugMessage(string.Format(
@@ -95,6 +118,7 @@
 				nearbyRelays.Count
 				));
 
+			// Remove all relays already checked this time.
 			nearbyRelays.RemoveAll(r => r.relayChecked);
 
 			Tools.PostDebugMessage(string.Format(
@@ -103,6 +127,8 @@
 				nearbyRelays.Count
 				));
 
+			// Remove all relays that cannot transmit.
+			// This call to r.CanTransmit() starts a depth-first recursive search for relays with a path back to Kerbin.
 			nearbyRelays.RemoveAll(r => !r.CanTransmit());
 
 			Tools.PostDebugMessage(string.Format(
@@ -111,12 +137,17 @@
 				nearbyRelays.Count
 				));
 
+			// Sort the available relays by distance.
 			nearbyRelays.Sort(new RelayComparer(this.vessel));
 
+			// Get the nearest available relay, or null if there are no available relays nearby.
 			IAntennaRelay nearestRelay = nearbyRelays.FirstOrDefault();
 
+			// Now that we're done with our recursive CanTransmit checks, flag this relay as not checked so it can be
+			// used next time.
 			this.relayChecked = false;
 
+			// Return the nearest available relay, or null if there are no available relays nearby.
 			return nearestRelay;
 		}
 
@@ -128,20 +159,39 @@
 		{
 			this.vessel = v;
 
+			// HACK: This might not be safe in all circumstances, but since AntennaRelays are not built until Start,
+			// we hope it is safe enough.
 			this.Kerbin = FlightGlobals.Bodies.FirstOrDefault(b => b.name == "Kerbin");
 		}
 
+		/*
+		 * Class implementing IComparer<IAntennaRelay> for use in sorting relays by distance.
+		 * */
 		internal class RelayComparer : IComparer<IAntennaRelay>
 		{
+			/// <summary>
+			/// The reference Vessel (usually the active vessel).
+			/// </summary>
 			protected Vessel referenceVessel;
 
+			// We don't want no stinking public parameterless constructors.
 			private RelayComparer() {}
 
+			/// <summary>
+			/// Initializes a new instance of the <see cref="AntennaRange.AntennaRelay+RelayComparer"/> class for use
+			/// in sorting relays by distance.
+			/// </summary>
+			/// <param name="reference">The reference Vessel</param>
 			public RelayComparer(Vessel reference)
 			{
 				this.referenceVessel = reference;
 			}
 
+			/// <summary>
+			/// Compare the <see cref="IAntennaRelay"/>s "one" and "two".
+			/// </summary>
+			/// <param name="one">The first IAntennaRelay in the comparison</param>
+			/// <param name="two">The second IAntennaRelay in the comparison</param>
 			public int Compare(IAntennaRelay one, IAntennaRelay two)
 			{
 				double distanceOne;

--- a/Extensions.cs
+++ b/Extensions.cs
@@ -4,33 +4,65 @@
 
 namespace AntennaRange
 {
+	/*
+	 * A class of utility extensions for Vessels and Relays to help find a relay path back to Kerbin.
+	 * */
 	public static class Extensions
 	{
+		/// <summary>
+		/// Returns the distance between this Vessel and another Vessel.
+		/// </summary>
+		/// <param name="vesselOne">This <see cref="Vessel"/><see ></param>
+		/// <param name="vesselTwo">Another <see cref="Vessel"/></param>
 		public static double DistanceTo(this Vessel vesselOne, Vessel vesselTwo)
 		{
 			return (vesselOne.GetWorldPos3D() - vesselTwo.GetWorldPos3D()).magnitude;
 		}
 
+		/// <summary>
+		/// Returns the distance between this Vessel and a CelestialBody
+		/// </summary>
+		/// <param name="vessel">This Vessel</param>
+		/// <param name="body">A <see cref="CelestialBody"/></param>
 		public static double DistanceTo(this Vessel vessel, CelestialBody body)
 		{
 			return (vessel.GetWorldPos3D() - body.position).magnitude;
 		}
 
+		/// <summary>
+		/// Returns the distance between this IAntennaRelay and a Vessel
+		/// </summary>
+		/// <param name="relay">This <see cref="IAntennaRelay"/></param>
+		/// <param name="Vessel">A <see cref="Vessel"/></param>
 		public static double DistanceTo(this IAntennaRelay relay, Vessel Vessel)
 		{
 			return relay.vessel.DistanceTo(Vessel);
 		}
 
+		/// <summary>
+		/// Returns the distance between this IAntennaRelay and a CelestialBody
+		/// </summary>
+		/// <param name="relay">This <see cref="IAntennaRelay"/></param>
+		/// <param name="body">A <see cref="CelestialBody"/></param>
 		public static double DistanceTo(this IAntennaRelay relay, CelestialBody body)
 		{
 			return relay.vessel.DistanceTo(body);
 		}
 
+		/// <summary>
+		/// Returns the distance between this IAntennaRelay and another IAntennaRelay
+		/// </summary>
+		/// <param name="relayOne">This <see cref="IAntennaRelay"/></param>
+		/// <param name="relayTwo">Another <see cref="IAntennaRelay"/></param>
 		public static double DistanceTo(this IAntennaRelay relayOne, IAntennaRelay relayTwo)
 		{
 			return relayOne.DistanceTo(relayTwo.vessel);
 		}
 
+		/// <summary>
+		/// Returns all of the PartModules or ProtoPartModuleSnapshots implementing IAntennaRelay in this Vessel.
+		/// </summary>
+		/// <param name="vessel">This <see cref="Vessel"/></param>
 		public static IEnumerable<IAntennaRelay> GetAntennaRelays (this Vessel vessel)
 		{
 			Tools.PostDebugMessage(string.Format(
@@ -41,6 +73,7 @@
 
 			List<IAntennaRelay> Transmitters;
 
+			// If the vessel is loaded, we can fetch modules implementing IAntennaRelay directly.
 			if (vessel.loaded) {
 				Tools.PostDebugMessage(string.Format(
 					"{0}: vessel {1} is loaded.",
@@ -48,10 +81,14 @@
 					vessel.name
 					));
 
+				// Gets a list of PartModules implementing IAntennaRelay
 				Transmitters = vessel.Parts
 					.SelectMany (p => p.Modules.OfType<IAntennaRelay> ())
 					.ToList();
-			} else {
+			}
+			// If the vessel is not loaded, we need to find ProtoPartModuleSnapshots with a true IsAntenna field.
+			else
+			{
 				Tools.PostDebugMessage(string.Format(
 					"{0}: vessel {1} is not loaded.",
 					"IAntennaRelay",
@@ -60,10 +97,13 @@
 
 				Transmitters = new List<IAntennaRelay>();
 
+				// Loop through the ProtoPartModuleSnapshots in this Vessel
 				foreach (ProtoPartModuleSnapshot ms in vessel.protoVessel.protoPartSnapshots.SelectMany(ps => ps.modules))
 				{
+					// If they are antennas...
 					if (ms.IsAntenna())
 					{
+						// ...add a new ProtoAntennaRelay wrapper to the list.
 						Transmitters.Add(new ProtoAntennaRelay(ms, vessel));
 					}
 				}
@@ -76,14 +116,17 @@
 				Transmitters.Count
 				));
 
+			// Return the list of IAntennaRelays
 			return Transmitters;
 		}
 
+		// Returns true if this PartModule contains a True IsAntenna field, false otherwise.
 		public static bool IsAntenna (this PartModule module)
 		{
 			return module.Fields.GetValue<bool> ("IsAntenna");
 		}
 
+		// Returns true if this ProtoPartModuleSnapshot contains a persistent True IsAntenna field, false otherwise
 		public static bool IsAntenna(this ProtoPartModuleSnapshot protomodule)
 		{
 			bool result;

--- a/IAntennaRelay.cs
+++ b/IAntennaRelay.cs
@@ -3,14 +3,40 @@
 
 namespace AntennaRange
 {
+	/*
+	 * Interface defining the basic functionality of AntennaRelay modules for AntennaRange.
+	 * */
 	public interface IAntennaRelay
 	{
+		/// <summary>
+		/// Gets the parent Vessel.
+		/// </summary>
+		/// <value>The parent Vessel.</value>
 		Vessel vessel { get; }
 
+		/// <summary>
+		/// Gets the distance to the nearest relay or Kerbin, whichever is closer.
+		/// </summary>
+		/// <value>The distance to the nearest relay or Kerbin, whichever is closer.</value>
+		double transmitDistance { get; }
+
+		/// <summary>
+		/// The maximum distance at which this relay can operate.
+		/// </summary>
+		/// <value>The max transmit distance.</value>
 		float maxTransmitDistance { get; }
 
+		/// <summary>
+		/// Gets a value indicating whether this <see cref="AntennaRange.ProtoDataTransmitter"/> has been checked during
+		/// the current relay attempt.
+		/// </summary>
+		/// <value><c>true</c> if relay checked; otherwise, <c>false</c>.</value>
 		bool relayChecked { get; }
 
+		/// <summary>
+		/// Determines whether this instance can transmit.
+		/// </summary>
+		/// <returns><c>true</c> if this instance can transmit; otherwise, <c>false</c>.</returns>
 		bool CanTransmit();
 	}
 }

--- a/ProtoAntennaRelay.cs
+++ b/ProtoAntennaRelay.cs
@@ -2,7 +2,11 @@
 
 namespace AntennaRange
 {
-	public class ProtoAntennaRelay : AntennaRelay
+	/*
+	 * Wrapper class for ProtoPartModuleSnapshot extending AntennaRelay and implementing IAntennaRelay.
+	 * This is used for finding relays in unloaded Vessels.
+	 * */
+	public class ProtoAntennaRelay : AntennaRelay, IAntennaRelay
 	{
 		protected ProtoPartModuleSnapshot snapshot;
 
@@ -20,6 +24,11 @@
 			}
 		}
 
+		/// <summary>
+		/// Gets a value indicating whether this <see cref="AntennaRange.ProtoDataTransmitter"/> has been checked during
+		/// the current relay attempt.
+		/// </summary>
+		/// <value><c>true</c> if relay checked; otherwise, <c>false</c>.</value>
 		public override bool relayChecked
 		{
 			get
@@ -30,10 +39,22 @@
 			}
 			protected set
 			{
-				this.snapshot.moduleValues.SetValue("relayChecked", value.ToString());
+				if (this.snapshot.moduleValues.HasValue("relayChecked"))
+				{
+					this.snapshot.moduleValues.SetValue("relayChecked", value.ToString ());
+				}
+				else
+				{
+					this.snapshot.moduleValues.AddValue("relayChecked", value);
+				}
 			}
 		}
 
+		/// <summary>
+		/// Initializes a new instance of the <see cref="AntennaRange.ProtoAntennaRelay"/> class.
+		/// </summary>
+		/// <param name="ms">The ProtoPartModuleSnapshot to wrap</param>
+		/// <param name="vessel">The parent Vessel</param>
 		public ProtoAntennaRelay(ProtoPartModuleSnapshot ms, Vessel vessel) : base(vessel)
 		{
 			this.snapshot = ms;