Added some more comments throughout the code