Added some comments to make some tricks more clear.