Changed from [Enum] metadata to require all enums to implement IEnum interface.

Fixed a couple of bugs, and refactored some code.