Changed output files to list, fasta and mat files. Fixed global assignments.