clean up and add comments to the R files