Fix a bug that "flags" is not correctly initialized.