fixes for data migration to DB. some misc tweaks/fixes.