Initial version of the script, just added a few comments.