             self.outputs = Array(outputs.values)
         } else {
             self.outputs = []
+        }
+        
+        if let observers = observers {
+            self.observers = Array(observers.values)
+        } else {
+            self.observers = []
         }
 
         self.onStateUpdate = onStateUpdate

import JavaScriptCore

public typealias StateUpdateBlock = (String) -> Void

public class Game {
    fileprivate let context = JSContext()

    public let inputs:[Input]
    public let outputs:[Output]

    public var onStateUpdate: StateUpdateBlock?

    public init(story:String, inputs:[String:Input]?, outputs:[String:Output]?, onStateUpdate:StateUpdateBlock?) {
        if let inputs = inputs {
            self.inputs = Array(inputs.values)
        } else {


        if let outputs = outputs {
            outputs.forEach({ addOutput($0, output: $1) })
        }
        
        if let observers = observers {
            observers.forEach({ addObserver($0, observer: $1) })
        }

        context?.setObject(unsafeBitCast(stateUpdated, to: AnyObject.self), forKeyedSubscript: "stateUpdated" as (NSCopying & NSObjectProtocol)!)
