Migration script fixes

A few minor fixes to the migration script