made categorize.c flexible, and made it check for errors, as well.