Added comments to explain what this does.