fix some data migration bugs