Refactor state into unsigned integer

Now that we separated the level-determination itself, there
is no need to have a signed integer for this purpose. This
simplifies the masking.
3 files changed