Change some names and add comments to make things clearer