Added a few more comments to make the code a bit more refined.