Added plenty of comments to the php file