Add better support for datastore serialization. Need to add unittests.