Mask is created from scratch - this can be probably reduced to a table of 16 values - no need to create them on the fly.