So I don't have any big issue with this code. I would probably put more braces on the same lines, but I'm not sure that's anything we've collectively agreed upon.

My only ask is that maybe this stuff belongs in its own file rather than adding 300 lines to catalogutil.