Major refactor of enums so that they are represented by the enum objects rather than raw numbers.  This allows enum values to retain their type identity which was lost before.