 		transaction: (spec) ->
 			spec = spec || []
 
-			return new JEFRi.Transaction(spec, this._store)
+			return new JEFRi.Transaction(spec, @_store)
 
 		# Return an interned entity from the local instance matching spec.
 		#
 		# Spec requires an _type property and the entity key.
 		find: (spec) ->
-			if (typeof spec is "string") 
+			if (typeof spec is "string")
 				spec = {_type : spec}
 			to_return = []
-			r = this.definition(spec._type)
-			results = this._instances[spec._type]
-
-			if (spec.hasOwnProperty(r.key)) 
+			r = @definition(spec._type)
+			results = @_instances[spec._type]
+
+			if (spec.hasOwnProperty(r.key))
 				# If a key is set, return only that result.
-				if (results[spec[r.key]]) 
+				if (results[spec[r.key]])
 					to_return.push(results[spec[r.key]])
-			else 
+			else
 				# Add results to an array to clean up the return for the user.
-				_.each(results, (result) ->
-					to_return.push(result)
-				)
+				to_return.push(result) for key, result of results
 
 			return to_return
 


		# Save all the new entities.
		save_new: (store) ->
			transaction = this.transaction()
			_.trigger(this, 'saving')

			#Add all new entities to the transaction
			transaction.add(this._new)

			return this._save(transaction, store)

		# Save all entities with changes, including new entities.
		save_all: (store) ->
			transaction = this.transaction()
			_.trigger(this, 'saving')

			#Add all new entities to the transaction
			# Modified is keyed by type...
			_.each(this._modified, (modified) ->
				# ...and each key contains an object of entity instances
				_.each(modified, (entity) ->
					entity._persist(transaction)
				)
			)

			_.each(this._new, (neu) ->
				this.persist(neu)
			)

			return this._save(transaction, store)

		_save: (transaction, store) ->
			store = store || this._store
			return store.execute('persist', transaction).then(
				_.bind(this.expand, this)
			)

		# Returns transaction of all entities in local cache.
		get_transaction_dump: () ->
			transaction = this.transaction()

			#Add all entities to the transaction
			# _instances is keyed by type...
			_.each(this._instances, (instance) ->
				# ...and each key contains an object of entity instances
				_.each(instance, (entity) ->
					transaction.add(entity)
				)
			)

			return transaction
	})


				# Build an entity's constructor.
				definition.Constructor = (proto) ->
					self = @

					# Set the privileged accounting and property data.
					@_new = true
					@_modified = {_count: 0}
					@_fields = {}
					@_relationships = {}
					# Check for runtime prototype override.
					proto = proto || {}

