Added comments to describe the functions.