Fixed bug where improper file names would break loop and fixed pagination