fixed a bug on the flag management in chunks.