Buffer size and flags mask fix.