Fix category and mask bits