         done &&= _done
         allDeclarations[j] = _declarations or []
         allClear[j] = _clear or []
-        virtualParameterUpdates[j] = JSON.parse(JSON.stringify(_returnValue)) if _done
+        if _done
+          if not _returnValue
+            if counter & 1
+              callback(null, {code: 'script', message: 'Invalid virtual parameter return value'})
+            return counter = 0
+
+          ret = {}
+
+          if _returnValue.writable?
+            ret.writable = +!!_returnValue.writable
+          else if provision[1].writable? or provision[2].writable?
+            if counter & 1
+              callback(null, {code: 'script', message: 'Virtual parameter must provide declared attributes'})
+            return counter = 0
+
+          if _returnValue.value?
+            ret.value = device.sanitizeParameterValue(_returnValue.value)
+          else if provision[1].value? or provision[2].value?
+            if counter & 1
+              callback(null, {code: 'script', message: 'Virtual parameter must provide declared attributes'})
+            return counter = 0
+
+          virtualParameterUpdates[j] = ret
 
         if (counter -= 2) == 1
           allDeclarations = Array.prototype.concat.apply([], allDeclarations)

  )


commitVirtualParameter = (sessionContext, provision, update, toClear) ->
  attributes = {}

  timestamp = sessionContext.timestamp + sessionContext.iteration
  timestamp += 1 if provision[2]?

  if update.writable?
    attributes.writable = [timestamp, +update.writable]
  else if provision[1]?.writable? or provision[2]?.writable?
    throw new Error('Virtual parameter must provide declared attributes')

  if update.value?
    attributes.value = [timestamp, device.sanitizeParameterValue(update.value)]
  else if provision[1]?.value? or provision[2]?.value?
    throw new Error('Virtual parameter must provide declared attributes')

  return device.set(sessionContext.deviceData, ['VirtualParameters', provision[0]], timestamp, attributes, toClear)


rpcResponse = (sessionContext, id, rpcRes, callback) ->
  if id != generateRpcId(sessionContext)
    return callback(new Error('Request ID not recognized'))

  if not vparams
    return callback()

  timestamp = sessionContext.timestamp + sessionContext.iteration
  toClear = null
  for vpu, i in ret
    vpu[k] = [timestamp + (if vparams[i][2][k]? then 1 else 0), v] for k, v of vpu
    toClear = device.set(sessionContext.deviceData, ['VirtualParameters', vparams[i][0]], timestamp, vpu, toClear)

  clear(sessionContext, toClear, (err) ->
    return rpcRequest(sessionContext, null, callback)
