Some cleanup and made the code iterate through the csv in chronological frame order