Replaced some enums by enum class for type safety (plus fixed a case of undefined behavior).
Removed additional space