Adds comments, fixes looping problem when creating csv file, other small fixes