 			// special cases
 			if (baseDiff == null || diffToAdd == null || baseType != diffType || baseType != 'object')
 			{
-				if (diffType == 'object') // not a primitive, so make a copy
-					baseDiff = ObjectUtil.copy(diffToAdd);
-				else
-					baseDiff = diffToAdd;
+				baseDiff = copyObject(diffToAdd);
 			}
 			else if (baseDiff is Array && diffToAdd is Array)
 			{

						var oldTypedState:Object = baseLookup[objectName];
						if (oldTypedState is String || oldTypedState == null)
						{
							if (typedState is String || typedState == null)
								baseLookup[objectName] = typedState; // avoid unnecessary function call overhead
							else
								baseLookup[objectName] = ObjectUtil.copy(typedState);
						}
						else if (!(typedState is String || typedState == null)) // update dynamic state
						{

					// If the object specified in newState does not exist in oldState, we don't need to do anything further.
					// If the class is the same as before, then we can save a diff instead of the entire session state.
					// If the class changed, we can't save only a diff -- we need to keep the entire session state.
					if (oldTypedState != null && oldTypedState[DynamicState.CLASS_NAME] == className)
					{
						// Replace the sessionState in the new DynamicState object with the diff.
						className = null; // no change
						diffValue = computeDiff(oldTypedState[DynamicState.SESSION_STATE], sessionState);
						if (diffValue === undefined)
