Handle exceptions more gracefully, support h5py and matplotlib versions