Added thorough comments to all the code