             
             // Insert the Default profile into the Profiles table if it doesn't exist
             
-            if (try db.scalar(profiles.table.filter(profiles.profileId == 0).count)) == 0 {
+            if (try db.scalar(profiles.table.filter(profiles.name == "Default").count)) == 0 {
                 let insert = profiles.table.insert(profiles.name <- "Default")
                 _ = try? db.run(insert)
             }

            let phrases = dbObjects.Phrases()
            let data_sources = dbObjects.DataSources()
            
            // Create Ngrams table
            try? db.run(ngrams.table.create(ifNotExists: true) { t in
                t.column(ngrams.gram, primaryKey: true)

class dbObjects {
    
    let db_path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
    
    
    struct Ngrams {
        let table = Table("Ngrams")
