refactored the hdf5 saving code
reorganized some of the hdf5 stuff