rename variables for clarity and cleaned up some old comments