Reworked the migration to use far less memory