Some error fixing.
Added bitmasks.