Implement entity handles to replace raw pointers.
Minor code changes.