Inlined and removed many of the bitmasks.