Change mask to int to avoid generating copies