Improved logging and error messages.
added test for migration.