Fix stability problems introduced by migration of layer parameters to ValueBase type.

When layer recieves or outputs the parameter values we need to create an independent copy of ValueBase object.
That way we avoid memory problems and unauthorized changes for parameter.