Several issues fixed in the migration process.

Fixes #566