fixing some bugs with data migration