fix bugs in memory header, add flexarray.hh