Centralized H5 read/writing code for easier maintenance.