Breaking out write_hash and read_hash into separate functions and
using a function pointer to select which one at hash init time