Refactor categorize-item and uncategorize-item to remove duplication.