Add some comments and rename variables for clarity.