Allow state to be a record

Allow states that are map-like object but cannot be used as functions of their keys. (e.g. records) Just use the key as a function of the state.