cleanup bitmask handling

Signed-off-by: Marc Lefrançois <mlefrancois@mirego.com>