This and the next two lines would be my next target for refactoring. I think we can do a more reliable job at parsing the filenames.