Fixing bugs related to deep copy optimization.