FIX: bugs and database migration