Added comments to some of the functions