refactor enum code to do forward references of members

Refactored to switch to lazy evaluation of enum members, which also enables enum members to be evaluated in any order.