framework: init & flag meta data

make line90-107 a utility function, so that we can reuse it at line 111.