Added some comments to the code to make it a little easier to follow, there will be more comments to come.