Maybe check just in case that categories.size() is 1 too.
This checks for an empty category name at the first index of categories.
Is that what's in `categories` when just -debug (or -debug=1) is passed?