Add deepCopy utility function