Fixing deep copy problem