various bug fixes with the migration script