Added lots of cmments describing the basics of what the code is doing