Added some clarifying comments to the code.