Added documentation to the script around the various functions.