Added comments to describe parts of the code.