Revised entity definition code

Reimplemented the entity definition code; it's now easier to write
(define-<type> …) functions for new entity types.