Comments and minor formatting changes

Comments were added to the newer code and some formatting was done for a
section of code that was out of place.
-Added some form of crash prevention. It should now stop trying to read
arrays past their actual data. (Very minor)