Fix title issue and simplification of code to determine which category'class to use