More care with filepaths.  Added use of SQL "DISTINCT".