Rename Category class to Categories and fixed some memory leaks