better error handling

should avoir configuration problems issues
use localeCompare for sorting categories