Please add some comments to this, explaining what does what.