Added a few comments to make it more readable.