Tinkered a bit with the files and I found out that by eliminating the first three characters on each filename e.g. the '01_' in '01_0.jpg') should help restore the gallery's ordering. The number that comes after the underscore is the actual page number, not the numbers prior to the underscore.