Null pointer handling in catalog.c Fix potential deferencing potential null pointers; Small optimizations. Closes #123.