         new_hash = saneparam new_state
         set_state_string new_hash, history
     
-    _onChild: (var_path, handler) ->
+    _onChild: (var_path, handler) =>
         @binder.on var_path, handler
     
-    get: (var_path=[]) ->
+    get: (var_path=[]) =>
         get_path_val @binder.state, var_path
 
-    sub: (varname) -> new SubState @, varname
+    sub: (varname) => new SubState @, varname
 
 class SubState
     constructor: (@parent, @varname) ->
     
-    update: (changes, history=false) ->
+    update: (changes, history=false) =>
         subchanges = {}
         subchanges[@varname] = changes
         @parent.update subchanges, history
 
-    get: (var_path=[]) ->
+    get: (var_path=[]) =>
         var_path.unshift(@varname)
         @parent.get var_path
 
-    on: (handler) ->
+    on: (handler) =>
         @parent._onChild [@varname], handler
 
-    _onChild: (var_path, handler) ->
+    _onChild: (var_path, handler) =>
         var_path.unshift(@varname)
         @parent._onChild var_path, handler
     


deep_extend = (target, update) ->
    for subname, value of update
        if not _.isObject value
            target[subname] = value
            continue

        handler get_path_val(@state, var_path), undefined
    
    resetState: (new_state) =>
        old_state = @state
        @state = new_state
        for [var_path, handler] in @listeners
            new_val = get_path_val @state, var_path
            old_val = get_path_val old_state, var_path
            if _.isEqual new_val, old_val
                continue
            # TODO: Don't stop processing on exception
            handler(new_val, old_val)

# TODO: Hack for old browsers?
get_state_string = ->
