Added comments to clarify code.