let add_at_reset f = 
  at_reset_functions := f :: !at_reset_functions