migration script bugfixes