Refactoring + some asserts in migrate action + slightly improved logging