Adding check before deleting non empty categories (resolves #1)