factor out fits catalog-building