Fixing a bug with deleting a category and continue refactoring