Fix migration bugs