Write fast hdf5, refactor Lua code for m2