Added control of tag mask. Cleaned up bitwise stuff.