diff --git a/stix2/datastore/memory.py b/stix2/datastore/memory.py
index 52bf4c8..52da168 100644
--- a/stix2/datastore/memory.py
+++ b/stix2/datastore/memory.py
@@ -10,7 +10,6 @@ from stix2.base import _STIXBase
 from stix2.core import parse
 from stix2.datastore import DataSink, DataSource, DataStoreMixin
 from stix2.datastore.filters import FilterSet, apply_common_filters
-from stix2.utils import is_marking
 
 
 def _add(store, stix_data, allow_custom=True, version=None):
@@ -47,12 +46,10 @@ def _add(store, stix_data, allow_custom=True, version=None):
         else:
             stix_obj = parse(stix_data, allow_custom, version)
 
-        # Map ID directly to the object, if it is a marking.  Otherwise,
-        # map to a family, so we can track multiple versions.
-        if is_marking(stix_obj):
-            store._data[stix_obj["id"]] = stix_obj
-
-        else:
+        # Map ID to a _ObjectFamily if the object is versioned, so we can track
+        # multiple versions.  Otherwise, map directly to the object.  All
+        # versioned objects should have a "modified" property.
+        if "modified" in stix_obj:
             if stix_obj["id"] in store._data:
                 obj_family = store._data[stix_obj["id"]]
             else:
@@ -61,6 +58,9 @@ def _add(store, stix_data, allow_custom=True, version=None):
 
             obj_family.add(stix_obj)
 
+        else:
+            store._data[stix_obj["id"]] = stix_obj
+
 
 class _ObjectFamily(object):
     """
@@ -267,12 +267,12 @@ class MemorySource(DataSource):
         """
         stix_obj = None
 
-        if is_marking(stix_id):
-            stix_obj = self._data.get(stix_id)
-        else:
-            object_family = self._data.get(stix_id)
-            if object_family:
-                stix_obj = object_family.latest_version
+        mapped_value = self._data.get(stix_id)
+        if mapped_value:
+            if isinstance(mapped_value, _ObjectFamily):
+                stix_obj = mapped_value.latest_version
+            else:
+                stix_obj = mapped_value
 
         if stix_obj:
             all_filters = list(
@@ -300,17 +300,13 @@ class MemorySource(DataSource):
 
         """
         results = []
-        stix_objs_to_filter = None
-        if is_marking(stix_id):
-            stix_obj = self._data.get(stix_id)
-            if stix_obj:
-                stix_objs_to_filter = [stix_obj]
-        else:
-            object_family = self._data.get(stix_id)
-            if object_family:
-                stix_objs_to_filter = object_family.all_versions.values()
+        mapped_value = self._data.get(stix_id)
+        if mapped_value:
+            if isinstance(mapped_value, _ObjectFamily):
+                stix_objs_to_filter = mapped_value.all_versions.values()
+            else:
+                stix_objs_to_filter = [mapped_value]
 
-        if stix_objs_to_filter:
             all_filters = list(
                 itertools.chain(
                     _composite_filters or [],

Adding SCO to the MemoryStore results in error
Below an example of how to trigger the problem:

``` python
from stix2.v21 import observables
from stix2 import MemoryStore

mem_store = MemoryStore()

file_observable = observables.File(
    name="example.exe",
    size=68 * 1000,
    magic_number_hex="50000000",
    hashes={
        "SHA-256": "841a8921140aba50671ebb0770fecc4ee308c4952cfeff8de154ab14eeef4649"
    }
)

mem_store.add(file_observable)
```

I obtain the following traceback:

```
Traceback (most recent call last):
  File "C:/Users/user-1/example_project/mem_store.py", line 98, in <module>
    example()
  File "C:/Users/user-1/example_project/mem_store.py", line 94, in example
    mem_store.add(file_observable)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\__init__.py", line 216, in add
    return self.sink.add(*args, **kwargs)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 185, in add
    _add(self, stix_data, self.allow_custom, version)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 62, in _add
    obj_family.add(stix_obj)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 77, in add
    self.all_versions[obj["modified"]] = obj
  File "C:\Users\user-1\venv\lib\site-packages\stix2\base.py", line 195, in __getitem__
    return self._inner[key]
KeyError: 'modified'
```

diff --git a/stix2/test/v20/test_datastore_memory.py b/stix2/test/v20/test_datastore_memory.py
index fba96dd..7852746 100644
--- a/stix2/test/v20/test_datastore_memory.py
+++ b/stix2/test/v20/test_datastore_memory.py
@@ -423,3 +423,24 @@ def test_object_family_internal_components(mem_source):
 
     assert "latest=2017-01-27 13:49:53.936000+00:00>>" in str_representation
     assert "latest=2017-01-27 13:49:53.936000+00:00>>" in repr_representation
+
+
+def test_unversioned_objects(mem_store):
+    marking = {
+        "type": "marking-definition",
+        "id": "marking-definition--48e83cde-e902-4404-85b3-6e81f75ccb62",
+        "created": "1988-01-02T16:44:04.000Z",
+        "definition_type": "statement",
+        "definition": {
+            "statement": "Copyright (C) ACME Corp.",
+        },
+    }
+
+    mem_store.add(marking)
+
+    obj = mem_store.get(marking["id"])
+    assert obj["id"] == marking["id"]
+
+    objs = mem_store.all_versions(marking["id"])
+    assert len(objs) == 1
+    assert objs[0]["id"] == marking["id"]
diff --git a/stix2/test/v21/test_datastore_memory.py b/stix2/test/v21/test_datastore_memory.py
index 4f63a06..e07943c 100644
--- a/stix2/test/v21/test_datastore_memory.py
+++ b/stix2/test/v21/test_datastore_memory.py
@@ -438,3 +438,38 @@ def test_object_family_internal_components(mem_source):
 
     assert "latest=2017-01-27 13:49:53.936000+00:00>>" in str_representation
     assert "latest=2017-01-27 13:49:53.936000+00:00>>" in repr_representation
+
+
+def test_unversioned_objects(mem_store):
+    marking = {
+        "type": "marking-definition",
+        "spec_version": "2.1",
+        "id": "marking-definition--48e83cde-e902-4404-85b3-6e81f75ccb62",
+        "created": "1988-01-02T16:44:04.000Z",
+        "definition_type": "statement",
+        "definition": {
+            "statement": "Copyright (C) ACME Corp.",
+        },
+    }
+
+    file_sco = {
+        "type": "file",
+        "id": "file--bbd59c0c-1aa4-44f1-96de-80b8325372c7",
+        "name": "cats.png",
+    }
+
+    mem_store.add([marking, file_sco])
+
+    obj = mem_store.get(marking["id"])
+    assert obj["id"] == marking["id"]
+
+    obj = mem_store.get(file_sco["id"])
+    assert obj["id"] == file_sco["id"]
+
+    objs = mem_store.all_versions(marking["id"])
+    assert len(objs) == 1
+    assert objs[0]["id"] == marking["id"]
+
+    objs = mem_store.all_versions(file_sco["id"])
+    assert len(objs) == 1
+    assert objs[0]["id"] == file_sco["id"]

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
antlr4-python3-runtime==4.9.3
attrs==24.2.0
Babel==2.14.0
backcall==0.2.0
beautifulsoup4==4.13.3
bleach==6.0.0
bump2version==1.0.1
bumpversion==0.6.0
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
cfgv==3.3.1
chardet==5.2.0
charset-normalizer==3.4.1
colorama==0.4.6
coverage==7.2.7
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.9
docutils==0.17.1
entrypoints==0.4
exceptiongroup==1.2.2
fastjsonschema==2.21.1
filelock==3.12.2
identify==2.5.24
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
importlib-resources==5.12.0
iniconfig==2.0.0
ipython==7.34.0
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.17.3
jupyter_client==7.4.9
jupyter_core==4.12.0
jupyterlab-pygments==0.2.2
MarkupSafe==2.1.5
matplotlib-inline==0.1.6
mistune==3.0.2
nbclient==0.7.4
nbconvert==7.6.0
nbformat==5.8.0
nbsphinx==0.4.3
nest-asyncio==1.6.0
nodeenv==1.9.1
packaging==24.0
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pkgutil_resolve_name==1.3.10
platformdirs==4.0.0
pluggy==1.2.0
pre-commit==2.21.0
prompt_toolkit==3.0.48
ptyprocess==0.7.0
Pygments==2.17.2
pyproject-api==1.5.3
pyrsistent==0.19.3
pytest==7.4.4
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
pyzmq==26.2.1
requests==2.31.0
simplejson==3.20.1
six==1.17.0
snowballstemmer==2.2.0
soupsieve==2.4.1
Sphinx==1.8.6
sphinx-prompt==1.5.0
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib-websupport==1.2.4
-e git+https://github.com/oasis-open/cti-python-stix2.git@fdb00c4a8cfe7327bbac609f029b3ff2366b8ccd#egg=stix2
stix2-patterns==2.0.0
tinycss2==1.2.1
tomli==2.0.1
tornado==6.2
tox==4.8.0
traitlets==5.9.0
typing_extensions==4.7.1
urllib3==2.0.7
virtualenv==20.26.6
wcwidth==0.2.13
webencodings==0.5.1
zipp==3.15.0

name: cti-python-stix2
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - antlr4-python3-runtime==4.9.3
      - attrs==24.2.0
      - babel==2.14.0
      - backcall==0.2.0
      - beautifulsoup4==4.13.3
      - bleach==6.0.0
      - bump2version==1.0.1
      - bumpversion==0.6.0
      - cachetools==5.5.2
      - cfgv==3.3.1
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - colorama==0.4.6
      - coverage==7.2.7
      - decorator==5.1.1
      - defusedxml==0.7.1
      - distlib==0.3.9
      - docutils==0.17.1
      - entrypoints==0.4
      - exceptiongroup==1.2.2
      - fastjsonschema==2.21.1
      - filelock==3.12.2
      - identify==2.5.24
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==6.7.0
      - importlib-resources==5.12.0
      - iniconfig==2.0.0
      - ipython==7.34.0
      - jedi==0.19.2
      - jinja2==3.1.6
      - jsonschema==4.17.3
      - jupyter-client==7.4.9
      - jupyter-core==4.12.0
      - jupyterlab-pygments==0.2.2
      - markupsafe==2.1.5
      - matplotlib-inline==0.1.6
      - mistune==3.0.2
      - nbclient==0.7.4
      - nbconvert==7.6.0
      - nbformat==5.8.0
      - nbsphinx==0.4.3
      - nest-asyncio==1.6.0
      - nodeenv==1.9.1
      - packaging==24.0
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pkgutil-resolve-name==1.3.10
      - platformdirs==4.0.0
      - pluggy==1.2.0
      - pre-commit==2.21.0
      - prompt-toolkit==3.0.48
      - ptyprocess==0.7.0
      - pygments==2.17.2
      - pyproject-api==1.5.3
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - pyzmq==26.2.1
      - requests==2.31.0
      - simplejson==3.20.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - soupsieve==2.4.1
      - sphinx==1.8.6
      - sphinx-prompt==1.5.0
      - sphinxcontrib-serializinghtml==1.1.5
      - sphinxcontrib-websupport==1.2.4
      - stix2-patterns==2.0.0
      - tinycss2==1.2.1
      - tomli==2.0.1
      - tornado==6.2
      - tox==4.8.0
      - traitlets==5.9.0
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - virtualenv==20.26.6
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - zipp==3.15.0
prefix: /opt/conda/envs/cti-python-stix2

stix2/test/v21/test_datastore_memory.py::test_unversioned_objects
stix2/test/v20/test_datastore_memory.py::test_memory_source_get stix2/test/v20/test_datastore_memory.py::test_memory_source_get_nonexistant_object stix2/test/v20/test_datastore_memory.py::test_memory_store_all_versions stix2/test/v20/test_datastore_memory.py::test_memory_store_query stix2/test/v20/test_datastore_memory.py::test_memory_store_query_single_filter stix2/test/v20/test_datastore_memory.py::test_memory_store_query_empty_query stix2/test/v20/test_datastore_memory.py::test_memory_store_query_multiple_filters stix2/test/v20/test_datastore_memory.py::test_memory_store_save_load_file stix2/test/v20/test_datastore_memory.py::test_memory_store_save_load_file_no_name_provided stix2/test/v20/test_datastore_memory.py::test_memory_store_add_invalid_object stix2/test/v20/test_datastore_memory.py::test_memory_store_object_with_custom_property stix2/test/v20/test_datastore_memory.py::test_memory_store_object_creator_of_present stix2/test/v20/test_datastore_memory.py::test_memory_store_object_creator_of_missing stix2/test/v20/test_datastore_memory.py::test_memory_store_object_with_custom_property_in_bundle stix2/test/v20/test_datastore_memory.py::test_memory_store_custom_object stix2/test/v20/test_datastore_memory.py::test_relationships stix2/test/v20/test_datastore_memory.py::test_relationships_by_type stix2/test/v20/test_datastore_memory.py::test_relationships_by_source stix2/test/v20/test_datastore_memory.py::test_relationships_by_target stix2/test/v20/test_datastore_memory.py::test_relationships_by_target_and_type stix2/test/v20/test_datastore_memory.py::test_relationships_by_target_and_source stix2/test/v20/test_datastore_memory.py::test_related_to stix2/test/v20/test_datastore_memory.py::test_related_to_by_source stix2/test/v20/test_datastore_memory.py::test_related_to_by_target stix2/test/v20/test_datastore_memory.py::test_object_family_internal_components stix2/test/v20/test_datastore_memory.py::test_unversioned_objects stix2/test/v21/test_datastore_memory.py::test_memory_source_get stix2/test/v21/test_datastore_memory.py::test_memory_source_get_nonexistant_object stix2/test/v21/test_datastore_memory.py::test_memory_store_all_versions stix2/test/v21/test_datastore_memory.py::test_memory_store_query stix2/test/v21/test_datastore_memory.py::test_memory_store_query_single_filter stix2/test/v21/test_datastore_memory.py::test_memory_store_query_empty_query stix2/test/v21/test_datastore_memory.py::test_memory_store_query_multiple_filters stix2/test/v21/test_datastore_memory.py::test_memory_store_save_load_file stix2/test/v21/test_datastore_memory.py::test_memory_store_save_load_file_no_name_provided stix2/test/v21/test_datastore_memory.py::test_memory_store_add_invalid_object stix2/test/v21/test_datastore_memory.py::test_memory_store_object_with_custom_property stix2/test/v21/test_datastore_memory.py::test_memory_store_object_creator_of_present stix2/test/v21/test_datastore_memory.py::test_memory_store_object_creator_of_missing stix2/test/v21/test_datastore_memory.py::test_memory_store_object_with_custom_property_in_bundle stix2/test/v21/test_datastore_memory.py::test_memory_store_custom_object stix2/test/v21/test_datastore_memory.py::test_relationships stix2/test/v21/test_datastore_memory.py::test_relationships_by_type stix2/test/v21/test_datastore_memory.py::test_relationships_by_source stix2/test/v21/test_datastore_memory.py::test_relationships_by_target stix2/test/v21/test_datastore_memory.py::test_relationships_by_target_and_type stix2/test/v21/test_datastore_memory.py::test_relationships_by_target_and_source stix2/test/v21/test_datastore_memory.py::test_related_to stix2/test/v21/test_datastore_memory.py::test_related_to_by_source stix2/test/v21/test_datastore_memory.py::test_related_to_by_target stix2/test/v21/test_datastore_memory.py::test_object_family_internal_components
stix2/datastore/memory.py
stix2/datastore/memory.py