give each physical entity (static and dynamic) a typechecked opaque handle to C entity

This can be used to efficiently pass things around to C functions rather than looking up in
hash table by uid everytime. Might even allow removal of the uid system in longer run