Rename variables to be more descriptive. Add and edit comments. Remove some debug print calls.