Improve categories handling