Fixed bugs in the migration