Rewrote entities.functions implementation to use new memory system properly.

Added a type check in entities.datamaps._TypeObject._set_value to verify the type being set is correct before setting.