We should have a script to refresh the category table.
Currently we have populateCategory.php --force, but it won't be run for categories that have 0 entries, so bad entries can remain.
Could maybe be done by having populateCategory.php delete all existing entries beforehand.