fixed bug: the check for empty categories was in the wrong place, so
that empty categories still got listed.