Buffer size and flags mask fix.

Mask fix