Added some comments to help people understand what's going on.