Did a lot of refactoring on the catalog to keep things clean.
Also improved the loading code for some catalog tables.