added arrayvar IR,  fix flattening