Make migrating the categories more robust