Better migration

@xliiv @quamilek  please review.