Major refactoring: replace unscoped enums with scoped ones.