Fixed and issue with outputting the , too late
Fixed and issue with undefined index errors