Added some comments to explain things better.