     let userKeyboards = activeUserDefaults().array(forKey: kKeymanUserKeyboardsListKey)
     let index = indexForUserKeyboard(withID: keyboardID, languageID: languageID)
 
-    let kbDict: [String: String]
+    let kbDict: [String: String]?
     if let index = index {
-      kbDict = userKeyboards![index] as! [String: String]
+      kbDict = userKeyboards![index] as? [String: String]
     } else {
-      kbDict = keyboardsDictionary[key]!
+      kbDict = keyboardsDictionary[key]
     }
 
     let kbVersion = latestKeyboardFileVersion(withID: keyboardID) ?? "1.0"
-    let isRTL = kbDict[kKeymanKeyboardRTLKey]
+    let isRTL = kbDict?[kKeymanKeyboardRTLKey]
 
     var jsFont = jsFontString(font)
     var jsOskFont: String

let kKeymanDefaultLanguageName = "English"
let kKeymanDefaultKeyboardRTL = "N"
let kKeymanDefaultKeyboardFont = "{\"family\":\"LatinWeb\",\"files\":[\"DejaVuSans.ttf\",\"DejaVuSans.mobileconfig\"]}"

// JSON keys for language REST calls
let kKeymanOptionsKey = "options"

    let deviceType = (UIDevice.current.userInterfaceIdiom == .phone) ? "AppleMobile" : "AppleTablet"
    webView.evaluateJavaScript("setDeviceType('\(deviceType)');", completionHandler: nil)
    if (keyboardID == nil || languageID == nil) && !shouldReloadKeyboard {
      var newKb = kKeymanDefaultKeyboard
      let userData = kIsKeymanSystemKeyboard ? UserDefaults.standard : activeUserDefaults()
      if let currentKb = userData.dictionary(forKey: kKeymanUserCurrentKeyboardKey) as? [String: String] {
        let kbID = currentKb[kKeymanKeyboardIdKey]
