fix some bit masking