added a bunch of comments to *try* to make code more readable.