Make better use of mask to reduce overhead for message processing

Bug fixes
Signed-off-by: Aleksi Sapon <QcTechs@gmail.com>