Working master catalog script (still needs data-checking)