refactor enum code
Merge pull request #2568 from WalterBright/enum-refactor

refactor enum code to do forward references of members